Darren Smith
Well-known Member
- Joined
- Nov 23, 2020
- Messages
- 631
- Office Version
- 2019
- Platform
- Windows
This code has 2 sets of ranges both don't seem to work? The SrcDataRange & DesDataRange
One is Destination workbook other is Source workbook?
One is Destination workbook other is Source workbook?
VBA Code:
Sub Job_Record_Detail()
Application.ScreenUpdating = False
Dim Src As Workbook
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
FilePath = "\\TGS-SRV01\Share\ShopFloor\PRODUCTION\JOB BOOK\"
Filename = "JOB RECORD SHEET.xlsm"
Set Des = Workbooks("Automated Cardworker.xlsm")
Set JCM = Worksheets("Job Card Master")
Set SrcOpen = Workbooks.Open(FilePath & Filename)
Set Src = Workbooks("JOB RECORD SHEET.xlsm")
Set TGSR = Worksheets("TGS JOB RECORD")
Set SrcDataRange = Workbooks(Src).Worksheets(TGSR).Range("A2:NA").Select
Set DesDataRange = Workbooks(Des).Worksheets(JCM).Range("A2:Q").Select
DesDataRange("A4").Value = Application.WorksheetFunction.VLookup(DesDataRange("G4"), Range("SrcDataRange"), 40, 0)
Columns("A:Q").EntireColumn.AutoFit
Range("A4").Select
Src.Close
Application.ScreenUpdating = True
End Sub