View Single Post
  #7   Report Post  
Bob Phillips
 
Posts: n/a
Default

One way Max is to replace them

Dim sh
For Each sh In ActiveWorkbook.Worksheets
sh.Name = Replace(sh.Range("A2").Value, "/", "-")
Next sh


another ius to format dates

Dim sh
For Each sh In ActiveWorkbook.Worksheets
If IsDate(sh.Range("A2").Value) Then
sh.Name = Format(sh.Name, "yyyy-mmm-dd")
Else
sh.Name = sh.Range("A2").Value
End If
Next sh

Really we need a generic RgExp to replace all offending characters.

--
HTH

Bob Phillips

"Max" wrote in message
...
Hi Bob,

When I tested with *dates* in A2 (as per OP), hit the error at this line
sh.Name = sh.Range("A2").Value


Maybe due to an invalid character: "/" arising from the date for the
sheetname

How to modify to get over this ?
Thanks
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Bob Phillips" wrote in message
...
With VBA

For Each sh In ACtiveworkbbok.Worksheets
Next sh

--
HTH

Bob Phillips

"Mark T" <Mark wrote in message
...
If I have 100+ sheets with with data for a single day on each sheet.

The
date
of data located in cell A2. Is there a quick way to rename all the

sheets
to
match what is in cell A2 of each sheet.