VBA - Offset to delete rows above activecell

JoeRooney

Board Regular
Joined
Nov 27, 2017
Messages
116
Hi ,

I have the below code and it is working as expected except that it is also deleting the activecell row, I only want to delete the two rows above and leave the row of the activecell.

Can someone advise what I need to change in the offset so the activecell row is not deleted?

VBA Code:
Sub Find_Ex1()


Range("A:A").Find(What:="Renewal / Collected").Select

ActiveCell.Offset(2, 2).Range("A1").Select

If IsNumeric(ActiveCell.Value) And ActiveCell.Value <> 0 Then

MsgBox "Is a number and is not equal to zero"

Else

Range(ActiveCell.Row & ":" & ActiveCell.Offset(-2, 0).Row).Select

Selection.Delete Shift:=xlUp

End If


End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,130
Office Version
  1. 365
Platform
  1. Windows
Glad it's sorted & thanks for the feedback.
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Watch MrExcel Video

Forum statistics

Threads
1,114,019
Messages
5,545,527
Members
410,689
Latest member
ConfuzzledThomas
Top