SOLVED
Home

Macro for deleting certain rows in some of the worksheets

%3CLINGO-SUB%20id%3D%22lingo-sub-736208%22%20slang%3D%22en-US%22%3EMacro%20for%20deleting%20certain%20rows%20in%20some%20of%20the%20worksheets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-736208%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20everyone.%20I'm%20looking%20for%20a%20macro%20that%20could%20help%20me%20deleting%20different%20rows%20in%20different%20sheets.%20For%20example%20rows%205%20to%2050%20in%20worksheet%20A%2C%20rows%20number%207%20to%2040%20in%20worksheet%20B%20and%20the%20rows%20number%2010%20to%2060%20in%20worksheet%20C.%20I%20was%20wondering%20if%20someone%20could%20help%20me%20with%20it.%20Thanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-736208%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-736412%22%20slang%3D%22en-US%22%3ERe%3A%20Macro%20for%20deleting%20certain%20rows%20in%20some%20of%20the%20worksheets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-736412%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F258032%22%20target%3D%22_blank%22%3E%40Edrisbas%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20this%20Sub%20in%20VBA%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20Delete_Rows()%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E'%20Delete_RowsA%20Macro%3CBR%20%2F%3ESheets(%22A%22).Select%3CBR%20%2F%3ERows(%225%3A50%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Delete%20Shift%3A%3DxlUp%3CBR%20%2F%3E%3CBR%20%2F%3E'%20Delete_RowsB%20Macro%3CBR%20%2F%3ESheets(%22B%22).Select%3CBR%20%2F%3ERows(%227%3A40%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Delete%20Shift%3A%3DxlUp%3CBR%20%2F%3E%3CBR%20%2F%3E'%20Delete_RowsC%20Macro%3CBR%20%2F%3ESheets(%22C%22).Select%3CBR%20%2F%3ERows(%2210%3A60%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Delete%20Shift%3A%3DxlUp%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps!%3C%2FP%3E%3CP%3EPReagan%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-737611%22%20slang%3D%22en-US%22%3ERe%3A%20Macro%20for%20deleting%20certain%20rows%20in%20some%20of%20the%20worksheets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-737611%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F360420%22%20target%3D%22_blank%22%3E%40PReagan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt's%20exactly%20what%20I%20was%20looking%20for.%20Thank%20you%20very%20much.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Edrisbas
Occasional 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
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.