VBA macro required to change tab name based on cell value

macca_18380

New Member
Joined
May 15, 2024
Messages
22
Office Version
  1. 365
Hi All, thank you in advance for your help!

I would like to create a macro which renames a tab based upon the criteria in cell c3, c3 contains text selected via data validation. I have found this macro elsewhere and have entered into VBA for the specific sheet's code for which i'm trying to change the tab name, but when i do so i get a error message that says "compile error: Ambiguous name detected: Worksheet_Change"

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("C3")) Is Nothing Then
ActiveSheet.Name = ActiveSheet.Range("C3")
ElseIf Not Intersect(Target.Dependents, Range("C3")) Then
ActiveSheet.Name = ActiveSheet.Range("C3")
End If
End Sub

Any help on resolving this error would be greatly appreciated.

Best regards
Michael
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
You cannot have two procedures with the same name in one module. You must merge the code from both procedures into one.

Artik
 
Upvote 0
That error indicates that you have more than one Worksheet_Change macro in your workbook. Excel allows only one Worksheet_Change macro in the sheet code module. You will have to combine them into one macro. Perhaps you can post the other macro and explain in detail what you are trying to do.
 
Upvote 0

Forum statistics

Threads
1,224,259
Messages
6,177,480
Members
452,782
Latest member
ZCapitao

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