Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Auto file naming | Excel Discussion (Misc queries) | |||
Auto naming worksheets | Excel Discussion (Misc queries) | |||
Auto naming Tabs in a Workbook | Excel Discussion (Misc queries) | |||
Naming worksheets... | Excel Discussion (Misc queries) | |||
naming worksheets | Excel Worksheet Functions |