Tab Rename

bnspool

New Member
Joined
Aug 17, 2011
Messages
11
I am brand new to Excel forums and a rookie macro creator. I am looking for a simple code to rename each new tab to match a selected cell input (in this case cell B9).

What I have works, but triggers this message box every time inputs are made elsewhere on the sheet:

"The name (tab name) is not a valid Sheet name"

Here's the code I'm using:

Sub SheetCreateDated()
Dim newsht As Worksheet, ws As Worksheet
Dim ivalue As String
ivalue = Sheets("Claimant1").Range("B9").Value
For Each ws In Worksheets
If ws.Name = ivalue Then
MsgBox ("There is already a sheet with the name " & "*" & ivalue & "*")
Exit Sub
End If
Next ws
Set newsht = Worksheets.Add
With newsht
.Move After:=Sheets(Sheets.Count)
.Name = ivalue
End With
Sheets("Claimant1").UsedRange.Copy Destination:=newsht.Range("B9")
newsht.Range("A3").Value = ivalue
End Sub

Thanks in advance for any help you can provide!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I don't think so. I don't really understand the purpose of that event code except to give an error message if you rename a sheet.
 
Upvote 0
hmm - OK. So now what? I don't have any other code in place. This code did do what I wanted, only it kept giving me that message box when entering data to other areas of the sheet.
 
Upvote 0
Did i misunderstand? i deleted the whole code. You probably meant for me to delete only the portion containing pesky message...
 
Upvote 0
It works correctly - now that I correctly interpreted your original advice. Big thanks!

I have one more feature I want to build in before I give this spreadsheet to my HR rep to field test. Should I start a new thread for that?
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,789
Members
452,942
Latest member
VijayNewtoExcel

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