JARichard74
Board Regular
- Joined
- Dec 16, 2019
- Messages
- 114
- Office Version
- 365
- Platform
- Windows
I am trying to find the item in Range P2:P8 that is equal to "Price Criteria" or cell F22, copy the corresponding item in column I and paste it somewhere else lets say C15, C16 for now. This is the code I tried but I get method of object _global failed error on this row. Pretty sure the rest of the code is incorrect but I can't get passed the error. Any assistance appreciated.
VBA Code:
Sub GetPriceCriteria()
Dim i As Integer, a As Integer, LastRow As Long
Dim cell As Range
Dim Prep As Worksheet, All As Worksheet
With ThisWorkbook.Sheets("All")
For Each cell In Range("P2:P" & LastRow)
If Range("P" & cell.Row).Value = Range("F22").Value Then
Cells(i + 10, "F") = Range("I" & cell.Row)
End If
Next cell
End With
End Sub