Formula that returns the last valid value found within a range

electrox

New Member
Joined
May 20, 2016
Messages
9
Hi guys,

I've having a little problem with the LOOKUP formula, I have a range of 31 sheets "1:31" where there might be data in their cells , for sake of this examples let's use A1

So we have 31 A1s in a range of "1:31" and then I will create a Sheet "32" where its A1 needs to return or be equal to the last valid data found in the prior 31 A1s of the range.

So if the last of the A1s that has data is on sheet "20" then the A1 on sheet "32" has to be equal to A1 on sheet 20.

=LOOKUP(2,1/('1:31'!L5<>""),'1:31'!L5)

This formula should do the trick or am I incorrect?( I'm not an expert I'm just following what I have found on the internet )
The problem I have while I'm updating the range on this formula is that once is hit enter it transforms into this =LOOKUP(2,1/('1:[31]31'!L5<>""),'1:31'!L5) and I just get a #REF! error

Would greatly appreciate any help

Thanks!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Here's a UDF :
VBA Code:
Function LDC(rw&, col&)
Dim c&, x
For c = 31 To 1 Step -1
    If Sheets(c).Cells(rw, col) <> "" Then
       LDC = Sheets(c).Cells(rw, col)
       Exit For
    End If
Next
If LDC = 0 Then LDC = ""
End Function
To use it : on sheet 32 enter in A1 =LDC(ROW(),COLUMN()) and fill across and down as required.
 
Upvote 0
Solution
What version of Excel are you using?
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Here's a UDF :
VBA Code:
Function LDC(rw&, col&)
Dim c&, x
For c = 31 To 1 Step -1
    If Sheets(c).Cells(rw, col) <> "" Then
       LDC = Sheets(c).Cells(rw, col)
       Exit For
    End If
Next
If LDC = 0 Then LDC = ""
End Function
To use it : on sheet 32 enter in A1 =LDC(ROW(),COLUMN()) and fill across and down as required.
Thanks! I'll give it a try!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top