Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 447
Default Group Worksheets

How do you group worksheets in a macro so I can insert a row in the same
place in all worksheets? The problem is I will not know the names nor the
number of worksheets in the file as the user will add worksheets when needed.

Any and all help will be greatly appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Group Worksheets

Try something like the following:

Dim S1 As String
Dim S2 As String
Dim Arr() As String
S1 = "SHeet1"
S2 = "Sheet2"
ReDim Arr(1 To 2)
Arr(1) = S1
Arr(2) = S2
Worksheets(Arr).Select



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Karen" wrote in message
...
How do you group worksheets in a macro so I can insert a row in
the same
place in all worksheets? The problem is I will not know the
names nor the
number of worksheets in the file as the user will add
worksheets when needed.

Any and all help will be greatly appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Group Worksheets


Sub addline()
For Each Sheet In Sheets
On Error Resume Next
Sheet.Select
Rows(15).Insert
Next
Sheet1.Select

End Sub

or something like this {{;

--
bill

-----------------------------------------------------------------------
bill k's Profile: http://www.excelforum.com/member.php...info&userid=82
View this thread: http://www.excelforum.com/showthread.php?threadid=40024

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 447
Default Group Worksheets

Thanks, but this didn't work. I ended up with a runtime error on the last
line. What I need to do is group worksheets (the names and number of them
will be deterimined by the users) so I can insert an identiical row in each
of these worksheets. When I wrote the macro it recorded just the existing
worksheets. I have been trying to use the worksheet.count command, but am
not familiar enough with the array feature to know what to do next with that
number.

Thanks for helping me out.



"Chip Pearson" wrote:

Try something like the following:

Dim S1 As String
Dim S2 As String
Dim Arr() As String
S1 = "SHeet1"
S2 = "Sheet2"
ReDim Arr(1 To 2)
Arr(1) = S1
Arr(2) = S2
Worksheets(Arr).Select



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Karen" wrote in message
...
How do you group worksheets in a macro so I can insert a row in
the same
place in all worksheets? The problem is I will not know the
names nor the
number of worksheets in the file as the user will add
worksheets when needed.

Any and all help will be greatly appreciated.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Group Worksheets

Assuming you want the changes made to all of the selected sheets (selected by
the user) then this might do

Sub AllSheets()
Dim wks As Worksheet

For Each wks In ActiveWindow.SelectedSheets
MsgBox wks.Name
wks.Rows(5).Insert
Next wks
End Sub
--
HTH...

Jim Thomlinson


"Karen" wrote:

Thanks, but this didn't work. I ended up with a runtime error on the last
line. What I need to do is group worksheets (the names and number of them
will be deterimined by the users) so I can insert an identiical row in each
of these worksheets. When I wrote the macro it recorded just the existing
worksheets. I have been trying to use the worksheet.count command, but am
not familiar enough with the array feature to know what to do next with that
number.

Thanks for helping me out.



"Chip Pearson" wrote:

Try something like the following:

Dim S1 As String
Dim S2 As String
Dim Arr() As String
S1 = "SHeet1"
S2 = "Sheet2"
ReDim Arr(1 To 2)
Arr(1) = S1
Arr(2) = S2
Worksheets(Arr).Select



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Karen" wrote in message
...
How do you group worksheets in a macro so I can insert a row in
the same
place in all worksheets? The problem is I will not know the
names nor the
number of worksheets in the file as the user will add
worksheets when needed.

Any and all help will be greatly appreciated.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Group Worksheets

Worksheets.select

(if you want to get all of them)

Karen wrote:

How do you group worksheets in a macro so I can insert a row in the same
place in all worksheets? The problem is I will not know the names nor the
number of worksheets in the file as the user will add worksheets when needed.

Any and all help will be greatly appreciated.


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Group Worksheets

The code provided by Chip worked fine for me. Of course if you mispell a
sheet name you would get an error.

How is your user going to determine the name and number - how will you code
have access to this information?

--
Regards,
Tom Ogilvy

"Karen" wrote in message
...
Thanks, but this didn't work. I ended up with a runtime error on the last
line. What I need to do is group worksheets (the names and number of them
will be deterimined by the users) so I can insert an identiical row in

each
of these worksheets. When I wrote the macro it recorded just the existing
worksheets. I have been trying to use the worksheet.count command, but am
not familiar enough with the array feature to know what to do next with

that
number.

Thanks for helping me out.



"Chip Pearson" wrote:

Try something like the following:

Dim S1 As String
Dim S2 As String
Dim Arr() As String
S1 = "SHeet1"
S2 = "Sheet2"
ReDim Arr(1 To 2)
Arr(1) = S1
Arr(2) = S2
Worksheets(Arr).Select



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Karen" wrote in message
...
How do you group worksheets in a macro so I can insert a row in
the same
place in all worksheets? The problem is I will not know the
names nor the
number of worksheets in the file as the user will add
worksheets when needed.

Any and all help will be greatly appreciated.






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
I wish to group my worksheets under group tabs Art Excel Worksheet Functions 1 February 4th 10 09:37 PM
I wish to group my worksheets under group tabs CSI Excel Worksheet Functions 5 October 19th 06 09:25 PM
How do I group worksheets (Lotus 123 function is "Sheet>Group Shee jaking Excel Worksheet Functions 2 August 30th 05 02:09 PM
loop through a certain group of worksheets only Chris M Excel Programming 1 July 1st 05 01:02 AM
Cannot Group Seven Worksheets, only Six Josma Excel Discussion (Misc queries) 3 May 14th 05 02:29 AM


All times are GMT +1. The time now is 07:42 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"