Tab Names in Macro
Okay, that is fine. I will just use the code you gave me and let it paste to
each sheet, one at a time. Now, how should your code read so that sheets 1
and 2 are not selected?
Thanks again!
"Gord Dibben" wrote:
If you pre-select the sheets you need using CTRL + click you could change the
code to
Dim ws a s Worksheet
For Each ws In ActiveWindow.SelectedSheets
'transfer stuff
Next ws
Otherwise you would have to build an array of sheets based on some criteria.
Gord
On Thu, 28 Jun 2007 15:50:00 -0700, Cheri
wrote:
Geesh...I put my reply the wrong place :o)
Okay, adding on what I was doing since this did not work for me. My macro
selects the "Stats" worksheet and copies a range. It then selects a number
of tabs (can be different amounts depending on data copied). So, I may
select tabs 3-10 one time and 3-16 tabs another time depending on how many
tabs are in the particular workbook. (Tabs 1 and 2 would never be selected).
This way, I can copy the data to all subsequent sheets at one time. Is this
possible, or do I have to do each tab separately, using your code?
I appreciate your help!!!
"Gord Dibben" wrote:
Several ways to go about this.
In your code don't address the sheets by name or position.
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
'do your tranfer stuff
Next ws
If you did want to rename all the sheets(not necessary if code above used) this
macro can do it.
Sub NameWS()
'name sheets from a unique list in Column A on first sheet
On Error Resume Next
For i = 1 To Worksheets.Count
Sheets(i).Name = Sheets(1).Cells(i, 1).Value
Next i
End Sub
Gord Dibben MS Excel MVP
On Thu, 28 Jun 2007 14:44:02 -0700, Cheri
wrote:
I have a macro set up that selects each worksheet and transfers data to each
one. The macro selects the worksheet by name, so if I change a worksheet
name, the macro will not run.
I don't know much about arrays or dim'ing but I know this can be done.
What I would really, really like is a macro to name all worksheets from a
list on one worksheet. Then I would like to run another macro to transfer
the data to each sheet no matter what the sheet tab is named.
I hope I made this clear enough!
Thanks,
Cheri
|