View Full Version : Solved: Code that runs automatically when a dropdown object selection changes
pliskers
07-15-2009, 05:48 AM
I'd like some code that will change the name of a tab to match a dropdown box selection every time the selection (and the cell linked to it) changes.
Can this be done to happen automatically, linking the code to the dropdown box activity?
Thank you!
Bob Phillips
07-15-2009, 06:25 AM
Try this where H1 is the linked cell
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1" '<== change to suit
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Parent.Name = .Value
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.
pliskers
07-15-2009, 07:53 AM
fantastic! Thanks for the quick reply - it worked perfectly.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.