SOLVED

Macro for deleting certain rows in some of the worksheets

Copper Contributor

Hello everyone. I'm looking for a macro that could help me deleting different rows in different sheets. For example rows 5 to 50 in worksheet A, rows number 7 to 40 in worksheet B and the rows number 10 to 60 in worksheet C. I was wondering if someone could help me with it. Thanks.

2 Replies
best response confirmed by Edrisbas (Copper Contributor)
Solution

Hello @Edrisbas,

 

Try this Sub in VBA:

 

Sub Delete_Rows()

 

' Delete_RowsA Macro
Sheets("A").Select
Rows("5:50").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp

' Delete_RowsB Macro
Sheets("B").Select
Rows("7:40").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp

' Delete_RowsC Macro
Sheets("C").Select
Rows("10:60").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp

End Sub

 

Hope this helps!

PReagan

 

Hi@PReagan 

It's exactly what I was looking for. Thank you very much.

1 best response

Accepted Solutions
best response confirmed by Edrisbas (Copper Contributor)
Solution

Hello @Edrisbas,

 

Try this Sub in VBA:

 

Sub Delete_Rows()

 

' Delete_RowsA Macro
Sheets("A").Select
Rows("5:50").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp

' Delete_RowsB Macro
Sheets("B").Select
Rows("7:40").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp

' Delete_RowsC Macro
Sheets("C").Select
Rows("10:60").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp

End Sub

 

Hope this helps!

PReagan

 

View solution in original post