Please help with the vba code to delete data in the area (K3:O17) when it overlaps with data in the area (E8:H8), thank you very much
Please help with the vba code to delete data in the area (K3:O17) when it overlaps with data in the area (E8:H8), thank you very much
HGVIET,
I see that you haven't fixed your posts (both) as instructed, but I've had a change of heart for the benefit other forum members and visitors so they can get answers too.
This solution relates to the file from your first post.
The first thing I added was a check to see if there was a value to search for"
' check that there is a value to search for
If Range("F1").Value = "" Then
answer = MsgBox(" Enter a value in ''F1''.", vbOKOnly, " Value is missing.")
Exit Sub
End If
I also added a check in case the value is not in the range to be searched:
' check that the value is in the search range
Set where1 = Range("L8:P17").Find(Range("F1").Value)
If where1 Is Nothing Then
answer = MsgBox(" ''F1'' value not found.", vbOKOnly, " Value is missing.")
Exit Sub
End If
Deleting the value just required one additional line of code after the "flashing" is done:
If i >= freq Then Range(where2).ClearContents ' delete value
See file attached.
Cheers :-)