Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88081

Unable to find and Delete a row using a string value

$
0
0

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=0https://www.dropbox.com/s/3hxrpbcj1pjx7oc/Capture.JPG2.JPG?dl=0

Could anyone tell me where I did make a mistake!


Viewing all articles
Browse latest Browse all 88081

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>