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

I am trying to rename worksheets and used a macro found in one of the threads:

Sub name_um()
For Each ws In Worksheets
ws.Name = ws.Range("A1").Value
Next
End Sub

It works...but A1 on the numerous worksheets get their value from cells the
first worksheet. Some of the cells in the first worksheet have no value.

I am getting an when the macro comes to a worksheet that does not have a
value in A1. How can I get the program to skip that worksheet?

Please be easy in your response, as I am new to Macros.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Auto naming Worksheets

And some values may not be legal names for worksheets, too.

Sub name_um()
dim ws as worksheet
For Each ws In Worksheets
on error resume next
ws.Name = ws.Range("A1").Value
if err.number < 0 then
err.clear
beep
'or maybe
msgbox ws.name & " was not renamed"
end if
on error goto 0
Next ws
End Sub

Will Cendrowski wrote:

I am trying to rename worksheets and used a macro found in one of the threads:

Sub name_um()
For Each ws In Worksheets
ws.Name = ws.Range("A1").Value
Next
End Sub

It works...but A1 on the numerous worksheets get their value from cells the
first worksheet. Some of the cells in the first worksheet have no value.

I am getting an when the macro comes to a worksheet that does not have a
value in A1. How can I get the program to skip that worksheet?

Please be easy in your response, as I am new to Macros.


--

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
Auto file naming Jacquesvv Excel Discussion (Misc queries) 1 June 23rd 09 02:57 PM
Auto naming worksheets Kenny R Excel Discussion (Misc queries) 1 December 7th 06 09:38 PM
Auto naming Tabs in a Workbook Johnny Excel Discussion (Misc queries) 5 August 29th 06 04:42 PM
Naming worksheets... tojo107 Excel Discussion (Misc queries) 3 April 7th 05 07:29 PM
naming worksheets Shooter Excel Worksheet Functions 1 December 3rd 04 04:09 PM


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