ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete row and 3 rows below by range selected (https://www.excelbanter.com/excel-programming/378303-delete-row-3-rows-below-range-selected.html)

Corey

delete row and 3 rows below by range selected
 
The below code does not work, but how can i get it carry out what it says?

Private Sub CommandButton13_Click()
With activeworksheet
Dim rng As Range
Set rng = Range("A28,A32,A36,A40,A44,A48,A52,A56,A60")
If ActiveCell = rng Then ' <=== If selected cell is in range above ??
..Row -.Row + 4 '<==== Then delete the ROW that the selected cell is in and
the 3 ROWS below it ALSO??
..Delete

End If
End With
End Sub

Corey....



Ron de Bruin

delete row and 3 rows below by range selected
 
Try this

Sub test()
If Not Application.Intersect(Range("A28,A32,A36,A40,A44,A 48,A52,A56,A60"), ActiveCell) Is Nothing Then
ActiveCell.Resize(4).EntireRow.Delete
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Corey" wrote in message ...
The below code does not work, but how can i get it carry out what it says?

Private Sub CommandButton13_Click()
With activeworksheet
Dim rng As Range
Set rng = Range("A28,A32,A36,A40,A44,A48,A52,A56,A60")
If ActiveCell = rng Then ' <=== If selected cell is in range above ??
.Row -.Row + 4 '<==== Then delete the ROW that the selected cell is in and
the 3 ROWS below it ALSO??
.Delete

End If
End With
End Sub

Corey....



Corey

delete row and 3 rows below by range selected
 
will try it tomorrow.
Thanks for the reply Ron.
I have 100% confidence in you code.

Corey....
"Ron de Bruin" wrote in message
...
Try this

Sub test()
If Not
Application.Intersect(Range("A28,A32,A36,A40,A44,A 48,A52,A56,A60"),
ActiveCell) Is Nothing Then
ActiveCell.Resize(4).EntireRow.Delete
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Corey" wrote in message
...
The below code does not work, but how can i get it carry out what it
says?

Private Sub CommandButton13_Click()
With activeworksheet
Dim rng As Range
Set rng = Range("A28,A32,A36,A40,A44,A48,A52,A56,A60")
If ActiveCell = rng Then ' <=== If selected cell is in range above ??
.Row -.Row + 4 '<==== Then delete the ROW that the selected cell is in
and the 3 ROWS below it ALSO??
.Delete

End If
End With
End Sub

Corey....





All times are GMT +1. The time now is 02:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com