Forum Discussion
NorthernKarsten
Jun 07, 2021Copper Contributor
Using vlookup without overwriting values that isnt in the lookup sheet
Hi, im looking to use the vlookup function without overwriting the cells that isnt in the lookup table. My company have an excelsheet of all the item prices from our factories. When we are getting ...
HansVogelaar
Jun 07, 2021MVP
You cannot use a formula in column B for this - it would lead to circular references.
You can simply copy/paste the new prices, or if you prefer, run a macro:
Sub UpdatePrices()
Dim r As Long
Dim m As Long
With Worksheets("Item price sheet")
m = .Range("A" & .Rows.Count).End(xlUp).Row
For r = 2 To m
If .Range("C" & r).Value = "A" Then
.Range("B" & r).Value = Application.VLookup(.Range("A" & r).Value, _
Worksheets("Factory A New Prices").Range("A:B"), 2, False)
End If
Next r
End With
End Sub