I am trying to find and delete a row containing a specific value. For this, I use the following excel-VBA code but it shows an error and hence finds nothing (shows rfnd=nothing). My code is -
Sub Save_Data_on_Master_Sheet()
'''' Save Data on Master Sheet''''
Dim Str As String, rfnd As Range
Str = Sheets("MASTER_DATA").Range("P2")
Sheets("MASTER_DATA").Range("D5:D2000").Select
Set rfnd = Selection.Find(Str, After:=Sheets("MASTER_DATA").Range("D4"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
rfnd.EntireRow.Delete
End Sub
Links of screenshots https://www.dropbox.com/s/v0zfs575mjqz7ve/Capture.JPG?dl=0 https://www.dropbox.com/s/3hxrpbcj1pjx7oc/Capture.JPG2.JPG?dl=0
Could anyone tell me where I did make a mistake!