To find Vlookup dynamically

GirishDhruva

Active Member
Joined
Mar 26, 2019
Messages
308
Hi Everyone,
Here i have Vlookup which is auto generated by macro, but i need that with dynamic (means table size may vary EVERY MONTH, so the values with red color may change) can anyone help me with this

Code:
ActiveCell.FormulaR1C1 = "=VLOOKUP([COLOR=#b22222]RC[-19][/COLOR],'Live Employees'![COLOR=#b22222]R1C1:R73C10[/COLOR],10,0)"

Thank you in prior
 
Last edited:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Upvote 0
Code:
Sub vlookup()
Dim LastCol As Integer
Dim LastRow As Long

LastCol = Range("A1").End(xlToLeft).Column
LastRow = Range("A" & Rows.Count).End(xlUp).Row

couple of things, certain words are reserved so avoid calling the sub the same as you have in the code.

in LastRow you defined A1 when you were looking for the number itself, so her I removed 1
 
Upvote 0
Code:
Sub vlookup()
Dim LastCol As Integer
Dim LastRow As Long

LastCol = Range("A1").End(xlToLeft).Column
LastRow = Range("A" & Rows.Count).End(xlUp).Row

couple of things, certain words are reserved so avoid calling the sub the same as you have in the code.

in LastRow you defined A1 when you were looking for the number itself, so her I removed 1


Same thing i have tried but same error i am getting back and my code is below and i am trying to do Vlookup from sheet1 to sheet4.
Code:
Sub vlookup()
Dim LastCol As Integer
Dim LastRow As Long

Worksheets("Sheet1").Activate
LastCol = Range("A1").End(xlToLeft).Column
LastRow = Range("A" & Rows.Count).End(xlUp).Row
ActiveCell.Formula = "=VLOOKUP('A2','Sheet4'!Cells(LastRow,lastcol),2,0)"


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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