i am trying to figure out how to write the vba to locate a cell based on its value and then delete that current row and all rows that fall above it.
i am trying to figure out how to write the vba to locate a cell based on its value and then delete that current row and all rows that fall above it.
Hi
try the below code
ActiveCell.Value = 1 ActiveCell.Row.Delete Shift:=xlUp
RoyalRajan
Something like:
Sub foo() Dim stLookFor As String Dim rngLookIn As Range Dim c As Range ' change as necessary stLookFor = "CB" Set rngLookIn = Selection '-------------------- Set c = rngLookIn.Find(what:=stLookFor) If Not c Is Nothing Then Range("A1", c).EntireRow.Delete End Sub
let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source
If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE
Walking the tightrope between genius and eejit...
Just change this line:
to whatever you need it to be. This determines which range is searched for your value. So if you want to look everywhere in the active sheet, you could use:Set rngLookIn = Selection
Set rngLookIn = Activesheet.UsedRange
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks