Darren Smith
Well-known Member
- Joined
- Nov 23, 2020
- Messages
- 631
- Office Version
- 2019
- Platform
- Windows
Using VBA to find prices then fill prices to a different worksheet.
I created a code below but it won't run it skips over the code and nothing happens.
I created a code below but it won't run it skips over the code and nothing happens.
VBA Code:
Sub UpDate_Stock_Prices()
Dim JCMLastRow As Long, x As Long
Dim DataRng As Range
Dim PartsList As Worksheet
Dim PartsListLastRow As Long
Dim JCM As Worksheet
Set Lines_Color = Body_And_Vehicle_Type_Form.Add_Lines_And_Color
Set JCM = ThisWorkbook.Worksheets("Job Card Master")
Set PartsList = ThisWorkbook.Worksheets("Parts List")
JCMLastRow = JCM.Range("D" & Rows.Count).End(xlUp).Row
PartsListLastRow = PartsList.Range("A" & Rows.Count).End(xlUp).Row
Set DataRng = PartsList.Range("A2:B" & PartsListLastRow)
For x = 13 To JCMLastRow
On Error Resume Next
JCM.Range("O" & x).Value = Application.WorksheetFunction.VLookup( _
JCM.Range("D" & x).Value, DataRng, 2, False)
Next x
ThisWorkbook.Worksheets(PartsList).Columns(2).Calculate
End If
End Sub