View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
ShaneDevenshire ShaneDevenshire is offline
external usenet poster
 
Posts: 2,344
Default Rename worksheets

Hi,

You could try

Dim sh As Worksheet
For Each sh In Worksheets
With sh
.Name = .[F1] & " " & .[G1]
End With
Next sh

--
Thanks,
Shane Devenshire


"Patrick C. Simonds" wrote:

Well I have a partial solution to my problem in the form of:

=TEXT(F1,"General") & TEXT(G1," General")

Is there any way I can cause a space between the two results when it is
displayed. Currently it looks like 2009Qrt2. I would like 2009 Qrt2.

"Patrick C. Simonds" wrote in message
...
Any way to get this to work? I want the worksheets to rename based on the
values or cells F1 and G1 of each worksheet

Sub Rename_Worksheets()
'
' Macro1 Macro
' Macro recorded 12/19/2005 by Cathy Baker
'

'

'This code runs to rename the worksheets

Dim wks As String
Dim Sh As Worksheet

'Application.ScreenUpdating = False

wks = ActiveSheet.Name

Const sStr As String = "F1 " & "G1"

On Error GoTo ErrHandler
For Each Sh In ThisWorkbook.Worksheets
Sh.Name = Sh.Range(sStr).Value
Next Sh

Worksheets(wks).Activate

Exit Sub
ErrHandler:
'MsgBox "Cell" & sStr & "on sheet" & sh.Name & "is not valid sheet name"
Resume Next

'Application.ScreenUpdating = True
End Sub