Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 504
Default Sheet name change needed

Hi, I am new to programming but I would like to rename sheets based on drop
down lists. For example: on sheet1 I have a drop down that contains 2
choices, 1A or 2A that you can select...based on which one you choose, I
would like the name of sheet2 to be updated to match your selection from
sheet1. So, if I pick 1A from the dropdown on sheet1, sheet2 will be renamed
1A. Is this feasible? Thanks for any help,
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 4,624
Default Sheet name change needed

One way:

Put this in your worksheet 1 code module (right-click the worksheet tab
and choose View Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const sNAMECELL As String = "A1"
Const sERROR As String = "Invalid worksheet name in cell "
Dim sSheetName As String

With Target
If Not Intersect(.Cells, Range(sNAMECELL)) Is Nothing Then
sSheetName = .Parent.Range(sNAMECELL).Value
If Not sSheetName = "" Then
On Error Resume Next
.Parent.Parent.Sheets(2).Name = sSheetName
On Error GoTo 0
If Not sSheetName = .Parent.Parent.Sheets(2).Name Then _
MsgBox sERROR & sNAMECELL
End If
End If
End With
End Sub



In article ,
Kevin wrote:

Hi, I am new to programming but I would like to rename sheets based on drop
down lists. For example: on sheet1 I have a drop down that contains 2
choices, 1A or 2A that you can select...based on which one you choose, I
would like the name of sheet2 to be updated to match your selection from
sheet1. So, if I pick 1A from the dropdown on sheet1, sheet2 will be renamed
1A. Is this feasible? Thanks for any help,

  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 22,906
Default Sheet name change needed

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("A1")
If .Value < "" Then
Sheets(2).Name = Me.Range("A1").Value
End If
End With
stoppit:
Application.EnableEvents = True
End Sub

Right-click on the tab of Sheet1. Select "View Code".

Copy/paste the above into the sheet module.

Alt + q to return to Excel.

Choose from the dropdown in A1


Gord Dibben MS Excel MVP

On Fri, 7 Dec 2007 07:47:01 -0800, Kevin
wrote:

Hi, I am new to programming but I would like to rename sheets based on drop
down lists. For example: on sheet1 I have a drop down that contains 2
choices, 1A or 2A that you can select...based on which one you choose, I
would like the name of sheet2 to be updated to match your selection from
sheet1. So, if I pick 1A from the dropdown on sheet1, sheet2 will be renamed
1A. Is this feasible? Thanks for any help,


  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 504
Default Sheet name change needed

Thank you both for the fast responses...works perfect. The help is greatly
appreciated, -Kevin



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sheet name needed for formula JBW Excel Worksheet Functions 10 October 23rd 07 12:51 PM
carry over data to other sheet - help needed Svea Excel Discussion (Misc queries) 3 July 17th 06 07:46 AM
Are there any inventory forms that change quantities as needed? Nelson Excel Worksheet Functions 0 May 1st 06 06:11 PM
Help needed! - How do I save a filtered sheet? ROBinBRAMPTON Excel Discussion (Misc queries) 3 December 21st 05 12:29 AM
Time Sheet Calculation Help Needed! sax30 Excel Worksheet Functions 2 April 26th 05 08:08 PM


All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"