SAMCRO2014
Board Regular
- Joined
- Sep 3, 2015
- Messages
- 160
I have been trying to get my macro to auto fill a vlookup formula from cells E2 to the last row based on how many rows data is the spreadsheet "Data". This number will constantly change.
Here is my coding:
This is the result I get.
-- corrupted image removed --
What I am doing wrong?
Here is my coding:
VBA Code:
Dim Data As Worksheet
Set Data = ThisWorkbook.Sheets("Data")
Dim LastRowData As Long
LastRowData = Data.Cells(Rows.Count, 1).End(xlUp).Row
' Open Salary GL Workbook to see if the GL numbers are categorized as regular, overtime, premiums, other.
Range("E2").Select
Workbooks.Open Filename:= _
"J:\FinanceAdmin\Finance\Resource Management\Regional\2018-19\Salary Reconciliation\Planned vs Actuals\Look up Tables\Salary GL.xlsx"
Windows("2019.P#.Planned vs Actuals - 1237.v1.RXM.xlsm").Activate
Range("E2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-2],'[Salary GL.xlsx]Page1_1'!R2C1:R49C3,3,0)"
Range("E2").Select
Selection.AutoFill Destination:=Range("E2:E" & LastRowData)
This is the result I get.
-- corrupted image removed --
What I am doing wrong?
Last edited by a moderator: