View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Auto Naming Worksheets

Sub name_sheets()
For Each ws In Worksheets
If Trim(ws.Range("A1")) < "" ws.Name = ws.Range("A1").Value
Next
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Will Cendrowski" wrote:

I have a workbook that has multiple worksheets. I would like to name the
worksheets and used a macro that I found in one of the threads:

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

The macro works great but their are some A1 cells in some of the sheets that
will not be named until the user completes a master form and the name is
filtered to the corresponding sheet.

Being new to the macro world, how can I have the macro skip the sheets that
have a 'null' value in A1?