Darren Smith
Well-known Member
- Joined
- Nov 23, 2020
- Messages
- 631
- Office Version
- 2019
- Platform
- Windows
I am trying to fill in details to another workbook but I get error 1004 Unable to get the VLookup property of the worksheet function class.
How can I sort this error?
How can I sort this error?
VBA Code:
Private Sub Fill_Details_to_JobRecord_Click()
TurnOff
Application.ScreenUpdating = False
Dim SrcOpen As Workbook
Dim Des As Workbook
Dim JCM As Worksheet
Dim TGSR As Worksheet
Dim FilePath As String
Dim Filename As String
Dim DesDataRange As Range
Dim SrcDataRange As Range
Dim iRow As Integer
FilePath = "\\tgs-srv01\share\ShopFloor\PRODUCTION\JOB BOOK\"
Filename = "JOB RECORD SHEET.xlsm"
Set JCM = ThisWorkbook.Worksheets("Job Card Master")
Set SrcDataRange = JCM.Range("A13").CurrentRegion
' On Error GoTo ErrHandler
With JCM
iRow = .Range("S13:S" & .Rows.Count).Find("SELLING PRICE", LookIn:=xlValues, lookat:=xlWhole).Row
iRow = iRow + 4
End With
Set SrcOpen = Workbooks.Open(FilePath & Filename)
Set TGSR = SrcOpen.Worksheets("TGS JOB RECORD")
Windows("JOB RECORD SHEET.xlsm").Visible = True
TGSR.Range("V").Value = WorksheetFunction.VLookup(JCM.Range("G2"), iRow, 20, 0)
Range("V").Select
TGSR.Range("W").Value = WorksheetFunction.VLookup(JCM.Range("G2"), iRow + 16, 22, 0)
Range("W").Select
TGSR.Range("X").Value = WorksheetFunction.VLookup(JCM.Range("G2"), iRow + 18, 22, 0)
Range("X").Select
TGSR.Range("Y").Value = WorksheetFunction.VLookup(JCM.Range("G2"), iRow + 20, 22, 0)
Range("Y").Select
TGSR.Range("Z").Value = WorksheetFunction.VLookup(JCM.Range("G2"), iRow + 2, 22, 0)
Range("Z").Select
TGSR.Range("AA").Value = WorksheetFunction.VLookup(JCM.Range("G2"), iRow + 16, 24, 0)
Range("AA").Select
TGSR.Range("AB").Value = WorksheetFunction.VLookup(JCM.Range("G2"), iRow + 18, 24, 0)
Range("AB").Select
TGSR.Range("AB").Value = WorksheetFunction.VLookup(JCM.Range("G2"), iRow + 20, 24, 0)
Range("AB").Select
SrcOpen.Close
'ErrHandler:
' If Err = 1004 Then
' MsgBox "Fill Job Number in Job Card Master Sheet Cell G2"
' End If
TurnOn
End Sub