Avatar of Seamus2626
Flag for Ireland asked on

With Found Cell

Hi, i have some code that finds a cell.

What i want to do is say With Found Cell, delete everything above it, so all rows above that cell

What code would i use?

Microsoft Excel

Avatar of undefined
Last Comment

8/22/2022 - Mon

1) Do you want to use VBA or Excel formulas?
2) What exactly is With Found Cell? Is it the result of a find? Is it the selected one? If it's a find, how did you find it? With VBA, or manually?
Please be a bit more explicit so we can help you better :)

Something like this maybe?
Public Sub deleterowsabove()
Dim l As Long

For l = 1 To ActiveCell.Row - 1
Next l

End Sub

Open in new window


It should be Rows(l). And you don't need to delete one by one. A simple:
Range("A1:A" & ActiveCell.Row - 1).EntireRow.Delete
would do it all at once.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Rory Archibald

Something like:
   Range("A1", FoundCell.Offset(-1)).EntireRow.Delete

Open in new window

Rory Archibald

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Sorry was away there, Rorys was the one that worked for me.

Thanks Everyone