Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JDP JDP is offline
external usenet poster
 
Posts: 2
Default Macro for several worksheets

I have a spreadsheet with several workbooks. I would
like to be able to use a macro to delete certain data in
all my worksheets (there are about 25). I have created a
macro to delete the data in just one worksheet but cannot
figure out how to do it in more than one.

Thanks,

Jdp
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Macro for several worksheets

Sub Macro1()
For Each ws In Worksheets
ws.Select
Your code here
Next ws
End Sub
-----Original Message-----
I have a spreadsheet with several workbooks. I would
like to be able to use a macro to delete certain data in
all my worksheets (there are about 25). I have created

a
macro to delete the data in just one worksheet but

cannot
figure out how to do it in more than one.

Thanks,

Jdp
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Macro for several worksheets

Hi JDP,

you may use

Sub macro2()
Dim i As Integer
For i = 1 To 25
Sheets(i).Select
'your code here
Next
End Sub

But for this you really need to know that your sheets are
in the right sequence.

Safer is:
make a list of all the sheet-names you want to use, e.g.
putting them in a table from A1 to A25 and name this
range "MySheets"

Then the macro would be

Sub Macro1()
Dim rngName As Range
For Each rngName In Range("MySheets")
Sheets(rngName.Value).Select
'Your code here
Next rngName
End Sub

Best regards

Wolf

-----Original Message-----
Thank you very much, but won't this delete all my
sheets? I need it to stop after the 25th sheet (or only
do the first 25.
-----Original Message-----
Sub Macro1()
For Each ws In Worksheets
ws.Select
Your code here
Next ws
End Sub
-----Original Message-----
I have a spreadsheet with several workbooks. I would
like to be able to use a macro to delete certain data

in
all my worksheets (there are about 25). I have created

a
macro to delete the data in just one worksheet but

cannot
figure out how to do it in more than one.

Thanks,

Jdp
.

.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
JDP JDP is offline
external usenet poster
 
Posts: 2
Default Macro for several worksheets

Thanks Wolf. I think we are getting close. Right now I
am getting a "Compile Error. Wrong number of arguments or
invalid property assignment"

It doesn't like the Sheets parameter in the macro.

Any suggestions?

-----Original Message-----
Hi JDP,

you may use

Sub macro2()
Dim i As Integer
For i = 1 To 25
Sheets(i).Select
'your code here
Next
End Sub

But for this you really need to know that your sheets

are
in the right sequence.

Safer is:
make a list of all the sheet-names you want to use, e.g.
putting them in a table from A1 to A25 and name this
range "MySheets"

Then the macro would be

Sub Macro1()
Dim rngName As Range
For Each rngName In Range("MySheets")
Sheets(rngName.Value).Select
'Your code here
Next rngName
End Sub

Best regards

Wolf

-----Original Message-----
Thank you very much, but won't this delete all my
sheets? I need it to stop after the 25th sheet (or

only
do the first 25.
-----Original Message-----
Sub Macro1()
For Each ws In Worksheets
ws.Select
Your code here
Next ws
End Sub
-----Original Message-----
I have a spreadsheet with several workbooks. I would
like to be able to use a macro to delete certain data

in
all my worksheets (there are about 25). I have

created
a
macro to delete the data in just one worksheet but
cannot
figure out how to do it in more than one.

Thanks,

Jdp
.

.

.

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New Worksheets Macro Noahthek Excel Worksheet Functions 5 August 20th 08 09:29 PM
macro to all worksheets [email protected] New Users to Excel 2 February 22nd 08 02:00 PM
Run Macro for all worksheets saman110 via OfficeKB.com Excel Worksheet Functions 2 July 23rd 07 10:27 PM
Run a macro on multiple worksheets? J@Y Excel Discussion (Misc queries) 3 February 3rd 07 10:24 AM
Same macro - Different Worksheets!? PaulW Excel Discussion (Misc queries) 2 December 12th 06 11:55 AM


All times are GMT +1. The time now is 10:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"