VBA to rename all worksheets in workbook based on cell value

alistair23

New Member
Joined
Dec 19, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi all! I'm trying to rename all the worksheets in a workbook so the sheet name is = to contents of cell B3.
*Cell B3 contains a full name, _ and kanji characters (example: Chris Stevens_城田陸)

I tried using the below VBA but I get an error 'run time error 13' type mismatch...not sure how to fix this :(
Could someone help correcting this for me?
Thank you so much in advance!

Tried VBA:
Sub sample()
Dim sh As Worksheet
For Each sh In Worksheets
With sh
.Name = .Range("B3").Value
End With
Next sh
End Sub

1639899740018.png
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi, the double quotes in your image don't look the like normal double quotes in your post - try re-copying this code and see if it's any better.

VBA Code:
Sub sample()
Dim sh As Worksheet
For Each sh In Worksheets
    With sh
        .Name = .Range("B3").Value
    End With
Next sh
End Sub
 
Upvote 0
Hi
I wonder how to rename all the sheets with the same contents of range("B3")!!!
I would guess
Something like this
VBA Code:
Sub sample()
    Dim sh As Worksheet
    Dim i As Long
    i = 3
    For Each sh In Worksheets
        With sh
            .Name = .Range("B" & i).Value
        End With
        i = i + 1
    Next sh
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top