ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting rows from mutliple sheets (https://www.excelbanter.com/excel-programming/395642-deleting-rows-mutliple-sheets.html)

diba

Deleting rows from mutliple sheets
 
Hello--could someone please tell me a more effecient way to loop
through each sheet (all are named) & delete the first 5 rows instead
of the following:

Sheets("cc1").Select
Range("a1:a5").EntireRow.Delete
Sheets("cc2").Select
Range("a1:a5").EntireRow.Delete
Sheets("cc3").Select
Range("a1:a5").EntireRow.Delete

Thanks in advance. Diba


Gord Dibben

Deleting rows from mutliple sheets
 
Sub Deleting()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
ws.Range("A1:A5").EntireRow.Delete
Next ws
End Sub


Gord Dibben MS Excel MVP

On Thu, 16 Aug 2007 09:26:16 -0700, diba wrote:

Hello--could someone please tell me a more effecient way to loop
through each sheet (all are named) & delete the first 5 rows instead
of the following:

Sheets("cc1").Select
Range("a1:a5").EntireRow.Delete
Sheets("cc2").Select
Range("a1:a5").EntireRow.Delete
Sheets("cc3").Select
Range("a1:a5").EntireRow.Delete

Thanks in advance. Diba




All times are GMT +1. The time now is 01:17 AM.

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