Link to home
Start Free TrialLog in
Avatar of Seamus2626
Seamus2626Flag 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?

Thanks
Seamus
Avatar of Cluskitt
Cluskitt
Flag of Portugal image

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
    ActiveSheet.Rows(1).Delete
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.
Avatar of Rory Archibald
Something like:
   Range("A1", FoundCell.Offset(-1)).EntireRow.Delete

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seamus2626

ASKER

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

Thanks Everyone

Seamus