stillwillyboy
Technical User
The following is the correct code for pulling the needed info and putting it in the correct column on my timesheet. That is, up to a point.
Sub VLookUpCopiedPieceRate()
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = Range("A65536").End(xlUp).Row
Range("D1").Select 'D is the piece rate on timesheet
With Range("D1")
.Value = "=VLOOKUP(A1, JobsAll!$A$1:$B$" & LastRow & ", 2, FALSE)"
.AutoFill Destination:=Range(Cells(.Row, .Column), Cells(Cells(2, 1).End(xlDown).Row, .Column)), Type:=xlFillDefault
End With
Application.ScreenUpdating = True
End Sub
I have verified that JobsAll has data in Col B to pull.
If I use the following, it works up to row 36, starting in row 37, I get #N/A in my cells.
.Value = "=VLOOKUP(A1, JobsAll!$A$1:$B$" & LastRow & ", 2, FALSE)"
By trial and error, I discovered that if I use the following, it works till row 99. Adding a record in row 100 causes and Application error.
.Value = "=VLOOKUP(A1, JobsAll!$A$1:$B$654" & LastRow & ", 2, FALSE)"
Also by trial and error, I discovered that if I leave the rows of records at 99, but change my code to the following, then I get the Application error message.
.Value = "=VLOOKUP(A1, JobsAll!$A$1:$f$655" & LastRow & ", 2, FALSE)"
What is causing this? As with most application needs, I do not know ahead of time how many source records I will need to pull from plus I will have no way of knowing how many records I will need to put info in for processing.
I’m dazed and confused.
Bill
Sub VLookUpCopiedPieceRate()
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = Range("A65536").End(xlUp).Row
Range("D1").Select 'D is the piece rate on timesheet
With Range("D1")
.Value = "=VLOOKUP(A1, JobsAll!$A$1:$B$" & LastRow & ", 2, FALSE)"
.AutoFill Destination:=Range(Cells(.Row, .Column), Cells(Cells(2, 1).End(xlDown).Row, .Column)), Type:=xlFillDefault
End With
Application.ScreenUpdating = True
End Sub
I have verified that JobsAll has data in Col B to pull.
If I use the following, it works up to row 36, starting in row 37, I get #N/A in my cells.
.Value = "=VLOOKUP(A1, JobsAll!$A$1:$B$" & LastRow & ", 2, FALSE)"
By trial and error, I discovered that if I use the following, it works till row 99. Adding a record in row 100 causes and Application error.
.Value = "=VLOOKUP(A1, JobsAll!$A$1:$B$654" & LastRow & ", 2, FALSE)"
Also by trial and error, I discovered that if I leave the rows of records at 99, but change my code to the following, then I get the Application error message.
.Value = "=VLOOKUP(A1, JobsAll!$A$1:$f$655" & LastRow & ", 2, FALSE)"
What is causing this? As with most application needs, I do not know ahead of time how many source records I will need to pull from plus I will have no way of knowing how many records I will need to put info in for processing.
I’m dazed and confused.
Bill