I'm trying to rename multiple worksheets of a workbook from their default names of "Sheet1 (1), Sheet1 (2), Sheet1 (3),..." to the date value that is in the cell "B3" of each particular worksheet. I want to end up with worksheet names of the dates that are in their individual "B3" cells. There are no duplicate dates in any of the worksheets. The format of the date in cell "B3" of each worksheet is in the format of 14-Mar-2001
as an example. Here is the macro I'm trying to use but it gives me a
run-time error '1004'
Sub RenameTabs()
For x = 1 To Sheets.Count
If Worksheets(x).Range("B3").Value <> "" Then
Sheets(x).Name = Worksheets(x).Range("B3").Value
End If
Next
End Sub
Any help I can get would be greatly appreciated!
Sheets
andWorksheets
. This is not the same! WhileSheets
can contain worksheet and chart objects,Worksheets
only contains worksheets. Therefore there might exist 8 sheets (5 worksheets and 3 charts). So change allSheets
toWorksheets
. - Pᴇʜ