Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
MikeM
 
Posts: n/a
Default Rename all existing worksheet tabs

I would like to take an existing workbook and rename all the worksheet tabs
at one time. For example, I might have ten worksheets with various names and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Const sBase as string = "USA"
Dim i as long
Dim sh As Object

For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
I would like to take an existing workbook and rename all the worksheet

tabs
at one time. For example, I might have ten worksheets with various names

and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.



  #3   Report Post  
MikeM
 
Posts: n/a
Default

Bob:
Thanks so much for your quick reply! I tried it and it works perfectly.

Could it be set up so I could define the worksheet name before running the
macro? (by typing it into a cell or something like that)?

For example, one workbook might need to be USA1, USA2, etc. and another
might need to be CANADA1, CANADA2, etc.

"Bob Phillips" wrote:

Const sBase as string = "USA"
Dim i as long
Dim sh As Object

For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
I would like to take an existing workbook and rename all the worksheet

tabs
at one time. For example, I might have ten worksheets with various names

and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.




  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

Mike,

This will get it from A1 on Sheet1, change to suit

Dim sBase as string
Dim i as long
Dim sh As Object

sBase = Worksheets("Sheet1").Range("A1").Value
For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh



--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
Bob:
Thanks so much for your quick reply! I tried it and it works perfectly.

Could it be set up so I could define the worksheet name before running the
macro? (by typing it into a cell or something like that)?

For example, one workbook might need to be USA1, USA2, etc. and another
might need to be CANADA1, CANADA2, etc.

"Bob Phillips" wrote:

Const sBase as string = "USA"
Dim i as long
Dim sh As Object

For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
I would like to take an existing workbook and rename all the worksheet

tabs
at one time. For example, I might have ten worksheets with various

names
and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.






  #5   Report Post  
David McRitchie
 
Posts: n/a
Default

Or more likely set up the prefix with an InputBox

sBase = Application.InputBox("Supply Prefix for worksheet renaming", _
"Rename worksheets", "USA")
If sBase = "" Then
MsgBox "Cancelled by your command"
exit sub
end if

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Bob Phillips" wrote in message ...
Mike,

This will get it from A1 on Sheet1, change to suit

Dim sBase as string
Dim i as long
Dim sh As Object

sBase = Worksheets("Sheet1").Range("A1").Value
For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh



--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
Bob:
Thanks so much for your quick reply! I tried it and it works perfectly.

Could it be set up so I could define the worksheet name before running the
macro? (by typing it into a cell or something like that)?

For example, one workbook might need to be USA1, USA2, etc. and another
might need to be CANADA1, CANADA2, etc.

"Bob Phillips" wrote:

Const sBase as string = "USA"
Dim i as long
Dim sh As Object

For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
I would like to take an existing workbook and rename all the worksheet
tabs
at one time. For example, I might have ten worksheets with various

names
and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.









  #6   Report Post  
Bob Phillips
 
Posts: n/a
Default

Don't like InputBox Dave, would much rather type in a cell. Too easy to make
a mistake, maybe not with USA, but easy with Kazakhstan.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"David McRitchie" wrote in message
...
Or more likely set up the prefix with an InputBox

sBase = Application.InputBox("Supply Prefix for worksheet renaming",

_
"Rename worksheets", "USA")
If sBase = "" Then
MsgBox "Cancelled by your command"
exit sub
end if

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Bob Phillips" wrote in message

...
Mike,

This will get it from A1 on Sheet1, change to suit

Dim sBase as string
Dim i as long
Dim sh As Object

sBase = Worksheets("Sheet1").Range("A1").Value
For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh



--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
Bob:
Thanks so much for your quick reply! I tried it and it works

perfectly.

Could it be set up so I could define the worksheet name before running

the
macro? (by typing it into a cell or something like that)?

For example, one workbook might need to be USA1, USA2, etc. and

another
might need to be CANADA1, CANADA2, etc.

"Bob Phillips" wrote:

Const sBase as string = "USA"
Dim i as long
Dim sh As Object

For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
I would like to take an existing workbook and rename all the

worksheet
tabs
at one time. For example, I might have ten worksheets with

various
names
and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some

similar
questions, but none exactly like this one.)

Thanks.









  #7   Report Post  
MikeM
 
Posts: n/a
Default

Many thanks to you Bob, and David as well for such quick and informative
responses. This is the first time I've posted a question here and will
certainly continue to do so in the future!
Mike

"Bob Phillips" wrote:

Don't like InputBox Dave, would much rather type in a cell. Too easy to make
a mistake, maybe not with USA, but easy with Kazakhstan.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"David McRitchie" wrote in message
...
Or more likely set up the prefix with an InputBox

sBase = Application.InputBox("Supply Prefix for worksheet renaming",

_
"Rename worksheets", "USA")
If sBase = "" Then
MsgBox "Cancelled by your command"
exit sub
end if

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Bob Phillips" wrote in message

...
Mike,

This will get it from A1 on Sheet1, change to suit

Dim sBase as string
Dim i as long
Dim sh As Object

sBase = Worksheets("Sheet1").Range("A1").Value
For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh



--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
Bob:
Thanks so much for your quick reply! I tried it and it works

perfectly.

Could it be set up so I could define the worksheet name before running

the
macro? (by typing it into a cell or something like that)?

For example, one workbook might need to be USA1, USA2, etc. and

another
might need to be CANADA1, CANADA2, etc.

"Bob Phillips" wrote:

Const sBase as string = "USA"
Dim i as long
Dim sh As Object

For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
I would like to take an existing workbook and rename all the

worksheet
tabs
at one time. For example, I might have ten worksheets with

various
names
and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some

similar
questions, but none exactly like this one.)

Thanks.










  #8   Report Post  
MikeM
 
Posts: n/a
Default

David:
I tried this solution and it works nicely as well. Many thanks!
Mike

"David McRitchie" wrote:

Or more likely set up the prefix with an InputBox

sBase = Application.InputBox("Supply Prefix for worksheet renaming", _
"Rename worksheets", "USA")
If sBase = "" Then
MsgBox "Cancelled by your command"
exit sub
end if

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Bob Phillips" wrote in message ...
Mike,

This will get it from A1 on Sheet1, change to suit

Dim sBase as string
Dim i as long
Dim sh As Object

sBase = Worksheets("Sheet1").Range("A1").Value
For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh



--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
Bob:
Thanks so much for your quick reply! I tried it and it works perfectly.

Could it be set up so I could define the worksheet name before running the
macro? (by typing it into a cell or something like that)?

For example, one workbook might need to be USA1, USA2, etc. and another
might need to be CANADA1, CANADA2, etc.

"Bob Phillips" wrote:

Const sBase as string = "USA"
Dim i as long
Dim sh As Object

For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
I would like to take an existing workbook and rename all the worksheet
tabs
at one time. For example, I might have ten worksheets with various

names
and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.








  #9   Report Post  
Posted to microsoft.public.excel.misc
dford
 
Posts: n/a
Default Rename all existing worksheet tabs

I would like to rename just selected worksheets. Could a modification of this
code be possible?

"Bob Phillips" wrote:

Const sBase as string = "USA"
Dim i as long
Dim sh As Object

For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
I would like to take an existing workbook and rename all the worksheet

tabs
at one time. For example, I might have ten worksheets with various names

and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.




  #10   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Rename all existing worksheet tabs

Const sBase As String = "USA"
Dim i As Long
Dim sh As Object

For Each sh In ActiveWorkbook.Windows(1).SelectedSheets
i = i + 1
sh.Name = sBase & i
Next sh

--
HTH

Bob Phillips

(replace somewhere in email address with googlemail if mailing direct)

"dford" wrote in message
...
I would like to rename just selected worksheets. Could a modification of

this
code be possible?

"Bob Phillips" wrote:

Const sBase as string = "USA"
Dim i as long
Dim sh As Object

For Each sh In Activeworkbook.Sheets
i = i + 1
sh.name = sBase & i
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeM" <michael[dot]mittelmanl[at]db[dot]com wrote in message
...
I would like to take an existing workbook and rename all the worksheet

tabs
at one time. For example, I might have ten worksheets with various

names
and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.








  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Rename all existing worksheet tabs

Hello:

I would like to do this also. Is it possible to do without using VBA, but
simply a command in Excel?

"MikeM" wrote:

I would like to take an existing workbook and rename all the worksheet tabs
at one time. For example, I might have ten worksheets with various names and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.

  #12   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Rename all existing worksheet tabs

There's not in Excel's user interface that would allow you do to lots of renames
all at once. You'd need a macro or do it manually (over and over).

rizello wrote:

Hello:

I would like to do this also. Is it possible to do without using VBA, but
simply a command in Excel?

"MikeM" wrote:

I would like to take an existing workbook and rename all the worksheet tabs
at one time. For example, I might have ten worksheets with various names and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.


--

Dave Peterson
  #13   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 42
Default Rename all existing worksheet tabs

I have a similar need, but wish to rename the tabs by referencing the same
cell on each worksheet that contains an invoice number.

"Dave Peterson" wrote:

There's not in Excel's user interface that would allow you do to lots of renames
all at once. You'd need a macro or do it manually (over and over).

rizello wrote:

Hello:

I would like to do this also. Is it possible to do without using VBA, but
simply a command in Excel?

"MikeM" wrote:

I would like to take an existing workbook and rename all the worksheet tabs
at one time. For example, I might have ten worksheets with various names and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.


--

Dave Peterson

  #14   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Rename all existing worksheet tabs

One way:

Option Explicit
Sub testme01()
Dim wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
With wks
On Error Resume Next
.Name = .Range("a1").Text
If Err.Number < 0 Then
MsgBox .Name & " was not renamed"
Err.Clear
End If
On Error GoTo 0
End With
Next wks
End Sub

Wally wrote:

I have a similar need, but wish to rename the tabs by referencing the same
cell on each worksheet that contains an invoice number.

"Dave Peterson" wrote:

There's not in Excel's user interface that would allow you do to lots of renames
all at once. You'd need a macro or do it manually (over and over).

rizello wrote:

Hello:

I would like to do this also. Is it possible to do without using VBA, but
simply a command in Excel?

"MikeM" wrote:

I would like to take an existing workbook and rename all the worksheet tabs
at one time. For example, I might have ten worksheets with various names and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.


--

Dave Peterson


--

Dave Peterson
  #15   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 42
Default Rename all existing worksheet tabs

WOW! It's magic. Thank You Dave

"Dave Peterson" wrote:

One way:

Option Explicit
Sub testme01()
Dim wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
With wks
On Error Resume Next
.Name = .Range("a1").Text
If Err.Number < 0 Then
MsgBox .Name & " was not renamed"
Err.Clear
End If
On Error GoTo 0
End With
Next wks
End Sub

Wally wrote:

I have a similar need, but wish to rename the tabs by referencing the same
cell on each worksheet that contains an invoice number.

"Dave Peterson" wrote:

There's not in Excel's user interface that would allow you do to lots of renames
all at once. You'd need a macro or do it manually (over and over).

rizello wrote:

Hello:

I would like to do this also. Is it possible to do without using VBA, but
simply a command in Excel?

"MikeM" wrote:

I would like to take an existing workbook and rename all the worksheet tabs
at one time. For example, I might have ten worksheets with various names and
I'd like them all to be named USA1, USA2, USA3 and so on.

Can this be easily done with some VBA code? (I've seen some similar
questions, but none exactly like this one.)

Thanks.

--

Dave Peterson


--

Dave Peterson

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
Worksheet tabs viewing there of Anthony Excel Worksheet Functions 2 July 13th 05 04:46 PM
rename worksheet Anthony Excel Discussion (Misc queries) 4 July 13th 05 01:16 AM
how do i rename worksheet to equal cell name MissSunshineKiss Excel Worksheet Functions 2 June 28th 05 02:05 AM
HOW DO I DELETE A WORKSHEET IN EXCEL? NOT HIDE IT OR RENAME IT deborah.hill Excel Worksheet Functions 6 June 24th 05 04:33 PM
Auto color change to tabs in worksheet scaast Excel Worksheet Functions 1 November 5th 04 06:58 PM


All times are GMT +1. The time now is 09:34 PM.

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

About Us

"It's about Microsoft Excel"