I have a worksheet that is used to enter data that is then transferred to a log on a second sheet.
I want to have an if statement in place that stops people from doing duplicate updates. Currently I have a code that stops it updating if one cell is the same as the corresponding last cell of the log but I want to repeat this with 1 or 2 more cells in case the usual 'matching' cell needs to be the same for any reason.
I'm new to VBA, tried a couple of things but cannot get it to work.
My And would need to go after the first if statement so if the first statement is false the second one will be true to stop the log from being updated.
Dim WkBk As Workbook
Dim WkSht As Worksheet
Set WkBk = ThisWorkbook
Set WkSht = WkBk.Worksheets("Log")
If (WkBk.Worksheets("Data").Range("I17") = WkSht.Range("N" & WkSht.Rows.Count).End(xlUp)) Then
MsgBox "This entry has already been logged"
Set WkSht = Nothing
Set WkBk = Nothing
Exit Sub
End If
Aucun commentaire:
Enregistrer un commentaire