gingerbreadgrl
New Member
- Joined
- Aug 19, 2019
- Messages
- 48
Hi All,
I would like to run a macro to check to see if a sheet name exists, if it does exist, I would like to rename that sheet to be the contents of whatever is in cell B1 of that sheet. So far I have not had any luck with the using the following code, seems like it would be simple enough but I'm having trouble. Any thoughts would be much appreciated! Thanks, Gingerbreadgrl
I've also tried:
This didn't work either:
I would like to run a macro to check to see if a sheet name exists, if it does exist, I would like to rename that sheet to be the contents of whatever is in cell B1 of that sheet. So far I have not had any luck with the using the following code, seems like it would be simple enough but I'm having trouble. Any thoughts would be much appreciated! Thanks, Gingerbreadgrl
Code:
Sub SummaryReportMacro()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Record 2" Then
ws.Name = ws.Range("B1").Value
End If
Next ws
End Sub
I've also tried:
Code:
Sub SummaryReportMacro()
Dim sht As Worksheet
For Each sht In Sheets
If sht.Name = "Record 2" Then
Sheets("Record 2") = Range("B1").Value
End If
End Sub
This didn't work either:
Code:
Sub SummaryReportMacro()
'If Sheets("Record 2").Name Then Sheets("Record 2").Name = Range(B1).Value
End Sub