VLOOKUP in MACRO

brianpog

New Member
Joined
Nov 29, 2010
Messages
5
Is there any way that you can Input a value on VLOOKUP Table on MACRO. You will be prompt on what sheet you will lookup the value instead on Sheet 1 only

Sample :

ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],'Sheet1'!R1:R1048576,4,FALSE)"
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Do you want the sheet to be the same as the active cell? If yes...
Code:
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],R1:R1048576,4,FALSE)"


Otherwise...
Code:
strSheet$ = Application.InputBox("Enter thet lookup sheet name.", "Select Sheet", "Sheet1", Type:=2)
If strSheet = "False" Then Exit Sub 'User canceled
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],'" & strSheet & "'!R1:R1048576,4,FALSE)"
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

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