ShawnSPS
Board Regular
- Joined
- Mar 15, 2023
- Messages
- 61
- Office Version
- 2003 or older
- Platform
- Windows
I have written the following code to unhide an hidden worksheet called “Zblank” which is then copied and rename to “a clients name or business” as a new worksheet. What needs to happen is as the user is creating these new client tabs ”worksheets” I need to take the created “new client” and create a dropdown name list of those clients and place them into a worksheet call Znotes on a range of cells. Now I can currently do it manually with data validation but I don’t want to have the user manually updating the list each time they create a new client”spreadsheet” Any Ideas? This is the working code for the creation of those clients.
Public Sub CopySheetAndRenamePredefined()
On Error GoTo Copysheet_ERR
Dim newName As String
newName = InputBox("Enter New Client Name:")
If StrPtr(newName) = 0 Then
MsgBox ("User canceled!")
GoTo bailout
ElseIf newName = vbNullString Then
MsgBox ("User didn't enter anything!")
GoTo bailout
Else
' MsgBox ("User entered " & newName)
End If
Worksheets("zblank").Visible = True
Worksheets("zblank").Activate
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
ActiveSheet.Name = newName
Sort_Active_Book
Worksheets("zblank").Visible = flase
Worksheets(newName).Activate
[a2].Value = ActiveSheet.Name
Worksheets("zblank").Visible = flase
bailout:
GoTo Copysheet_EXIT
Copysheet_ERR:
If Err.Number = 1004 Then
Application.DisplayAlerts = False
MsgBox "DEuplicate Client Entered. Press 'OK' then re-run Macro."
Worksheets("Zblank (2)").Activate
Worksheets("Zblank (2)").DELETE
Worksheets("zblank").Visible = False
Application.DisplayAlerts = True
GoTo Copysheet_EXIT
End If
MsgBox Err.Number
Copysheet_EXIT:
Public Sub CopySheetAndRenamePredefined()
On Error GoTo Copysheet_ERR
Dim newName As String
newName = InputBox("Enter New Client Name:")
If StrPtr(newName) = 0 Then
MsgBox ("User canceled!")
GoTo bailout
ElseIf newName = vbNullString Then
MsgBox ("User didn't enter anything!")
GoTo bailout
Else
' MsgBox ("User entered " & newName)
End If
Worksheets("zblank").Visible = True
Worksheets("zblank").Activate
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
ActiveSheet.Name = newName
Sort_Active_Book
Worksheets("zblank").Visible = flase
Worksheets(newName).Activate
[a2].Value = ActiveSheet.Name
Worksheets("zblank").Visible = flase
bailout:
GoTo Copysheet_EXIT
Copysheet_ERR:
If Err.Number = 1004 Then
Application.DisplayAlerts = False
MsgBox "DEuplicate Client Entered. Press 'OK' then re-run Macro."
Worksheets("Zblank (2)").Activate
Worksheets("Zblank (2)").DELETE
Worksheets("zblank").Visible = False
Application.DisplayAlerts = True
GoTo Copysheet_EXIT
End If
MsgBox Err.Number
Copysheet_EXIT: