lookup to return last value in vba

p4nny

Board Regular
Joined
Jan 13, 2015
Messages
246
Hi,

I have the following formula which returns the last value in a lookup range.


LOOKUP(2,1/(case=D2),status)

I would now to replicate this in vba.. D2 would become a textbox called 'tbcasenum'

Any guidance would be appreciated
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi,

I have the following formula which returns the last value in a lookup range.


LOOKUP(2,1/(case=D2),status)

I would now to replicate this in vba.. D2 would become a textbox called 'tbcasenum'

Any guidance would be appreciated
Hi p4nny, is it not just...

Rich (BB code):
Sub LookupLastValue()
    Worksheets("Sheet1").Range("A5").Formula = "=LOOKUP(2,1/(case=D2),status)"
End Sub

...where the red bold can be changed to suit your sheet name and blue bold can be changed to suit where you want the formula to output to?
 
Upvote 0
Cheers for ther reply..

Sorry I wasn't clear enough. The vba will sit behind a userform so "tbcasenum" is the lookup value and not D2.

Many thanks for your help
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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