Hello
TD;DR: Find value in column A and if found replace value in another column
I have a list with sale ID and salesman ID on one sheet and a sheet with "fixes" for sales which were reported to have wrong salesman ID (this sheet also has sale ID and salesman ID). I need to replace salesman ID for sales in the report if the corresponding ID is in the fixes sheet, using VBA.
I already have VBA code using FIND but its incredibly slow when fixing thousands of rows. Anyone have a better idea? Thanks!
TD;DR: Find value in column A and if found replace value in another column
I have a list with sale ID and salesman ID on one sheet and a sheet with "fixes" for sales which were reported to have wrong salesman ID (this sheet also has sale ID and salesman ID). I need to replace salesman ID for sales in the report if the corresponding ID is in the fixes sheet, using VBA.
I already have VBA code using FIND but its incredibly slow when fixing thousands of rows. Anyone have a better idea? Thanks!
Code:
x = 2
Do While Len(ThisWorkbook.Sheets("fixes").Cells(x, 1)) > 0
sale_id = ThisWorkbook.Sheets("fixes").Cells(x, 1)
fixed_value = ThisWorkbook.Sheets("fixes").Cells(x, 5)
Set rng1 = ThisWorkbook.Sheets("sales").Range("A:A").Find(sale_id, , xlValues, xlWhole)
If Not rng1 Is Nothing Then
rng1.Offset(0, 8) = fixed_value
End If
x = x + 1
Loop
Last edited: