Darren Smith
Well-known Member
- Joined
- Nov 23, 2020
- Messages
- 631
- Office Version
- 2019
- Platform
- Windows
The code below opens workbook but returns #N/A or #Ref! in column No. 16
Private Sub Up_Date_Prices_Click()
Application.ScreenUpdating = False
Dim SrcOpen As Workbook
Dim Des As Workbook
Dim JCM As Worksheet
Dim PL As Worksheet
Dim FilePath As String
Dim Filename As String
Dim DesDataRange As Range
Dim SrcDataRange As Range
Dim LastRow As Long
Dim ComBox As Object
FilePath = "\\TGS-SRV01\Share\ShopFloor\PRODUCTION\PURCHASING\"
Filename = "TGS Group Inventory Sheet - Main.xlsx"
Set SrcOpen = Workbooks.Open(FilePath & Filename)
Set PL = SrcOpen.Worksheets("Part List")
LastRow = PL.Cells(PL.Rows.Count, "E").End(xlUp).row
Set SrcDataRange = PL.Range("E13:O" & LastRow)
Windows("TGS Group Inventory Sheet - Main.xlsx").Visible = False
Set Des = Workbooks("Automated Cardworker.xlsm")
Set JCM = Des.Worksheets("Job Card Master")
Set DesDataRange = JCM.Range("D13:O299")
Set ComBox = Me.Jobcard_Demands
JCM.Range("O13:O299").Value = Application.WorksheetFunction.VLookup(JCM.Range("D13:D299"), SrcDataRange, 16, 0)
Range("O13:O299").Select
Application.DisplayAlerts = False
SrcOpen.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub[/CODE]
Private Sub Up_Date_Prices_Click()
Application.ScreenUpdating = False
Dim SrcOpen As Workbook
Dim Des As Workbook
Dim JCM As Worksheet
Dim PL As Worksheet
Dim FilePath As String
Dim Filename As String
Dim DesDataRange As Range
Dim SrcDataRange As Range
Dim LastRow As Long
Dim ComBox As Object
FilePath = "\\TGS-SRV01\Share\ShopFloor\PRODUCTION\PURCHASING\"
Filename = "TGS Group Inventory Sheet - Main.xlsx"
Set SrcOpen = Workbooks.Open(FilePath & Filename)
Set PL = SrcOpen.Worksheets("Part List")
LastRow = PL.Cells(PL.Rows.Count, "E").End(xlUp).row
Set SrcDataRange = PL.Range("E13:O" & LastRow)
Windows("TGS Group Inventory Sheet - Main.xlsx").Visible = False
Set Des = Workbooks("Automated Cardworker.xlsm")
Set JCM = Des.Worksheets("Job Card Master")
Set DesDataRange = JCM.Range("D13:O299")
Set ComBox = Me.Jobcard_Demands
JCM.Range("O13:O299").Value = Application.WorksheetFunction.VLookup(JCM.Range("D13:D299"), SrcDataRange, 16, 0)
Range("O13:O299").Select
Application.DisplayAlerts = False
SrcOpen.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub[/CODE]