ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Working with multiple sheets (https://www.excelbanter.com/excel-programming/290860-working-multiple-sheets.html)

Jim[_22_]

Working with multiple sheets
 
Hi
I have a multiple sheet workbook that I want to delete the same cells in
each sheet. How do I set up a macro for someone else to do that if they are
constantly adding new duplicate sheets. I need a macro that will
automatically select the 2nd thru the last sheet so that the same cells on
all the those sheets can be deleted with one macro. Thanks! Jim



Bob Phillips[_6_]

Working with multiple sheets
 
Jim,

By delete, do you mean remove their values? Assuming so,

Sub DeleteCells(Rng )
Dim i As Long

For i = 2 To Worksheets.Count
Worksheets(i).Range(Rng.Address).ClearContents'cha nge ClearContents
to Clear to clear formats etc. as well
Next i
End Sub


run it like so

DeleteCells Range("A1:H100")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jim" wrote in message ...
Hi
I have a multiple sheet workbook that I want to delete the same cells in
each sheet. How do I set up a macro for someone else to do that if they

are
constantly adding new duplicate sheets. I need a macro that will
automatically select the 2nd thru the last sheet so that the same cells on
all the those sheets can be deleted with one macro. Thanks! Jim






All times are GMT +1. The time now is 03:56 PM.

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