Herbalgiraffe
New Member
- Joined
- Feb 22, 2020
- Messages
- 16
- Office Version
- 365
- Platform
- Windows
Hey guys, so long story short, I am trying to automate the process of updating item prices for my company, but for now I am just trying to create some sort of a For loop to do so. There are two worksheets involved, new prices to be input (Ws1), and the much larger current list of all items a customer may purchase, which holds the old pricing currently (Ws2). for sake of example Ws1 has maybe 200 items to be updated, and Ws2 has 1000. I need my loop to cycle through each item in Ws1, searching for a match in Ws2 so that upon identification, the new data is inputted on Ws2, which after updating is complete, gets uploaded back into a database. There are more steps for each found item, but for now I am just hoping to highlight found items on Ws2, and I will work on the rest from there. the other thing is that the amount of items in Ws1 and Ws2 can change depending on the customer, as not all customers buy all of our products. Is what I currently have somewhere close?
VBA Code:
Dim Ws1 As Range
Dim Ws2 As Range
Dim finalrow As Integer
Dim i As Integer
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
Set Ws2 = Range(Worksheets(Sheet2).Range("A1"), finalrow)
Set Ws1 = Range(Worksheets(Sheet1).Range("A1"), finalrow)
With ActiveSheet
For i = 2 To finalrow
If .Cells(Ws1) Like .Cells(Ws2) Then
cell.Interior.ColorIndex = 3
End If
Next
End With
End Sub