I'm trying to update one sheet with data from another sheet.
The update is working, but I want to have a check for values that don't exist.
Sheets(f_btc).Select
With Worksheets(f_btc)
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With Worksheets(f_btc).Range("A1:A" & LastRow)
For i = 1 To LastRow
Set c = .Find("HBN*", LookIn:=xlValues)
If Not c Is Nothing Then
' gather some data from the first sheet
WHBN = Range(c.Address).Value
HBNfakt = Range(c.Address).Offset(0, 1).Value
HBNmail = Range(c.Address).Offset(0, 2).Value
Range(c.Address).Value = ""
Range(c.Address).Offset(0, 1).Value = ""
Range(c.Address).Offset(0, 2).Value = ""
'Jump to the other sheet and find c.Address(WHBN)
Sheets(f_vol).Select
With Worksheets(f_vol)
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
End With
With Worksheets(f_vol).Range("B1:B" & LastRow)
'Here I want to check if the value WHDN exist on this sheet, if not show a message
Set D = .Find(WHBN, LookIn:=xlValues)
If Not D Is Nothing Then
Range(D.Address).Offset(0, 2).Value = HBNfakt
Range(D.Address).Offset(0, 16).Value = HBNmail
Else
MsgBox ("Can not find: " & D)
End If
End With
Sheets(f_btc).Select
Set c = .FindNext(c)
End If
Next i
End With
Bookmarks