How can I automatically create a new sheet titled with a specific data input?

Jbab

New Member
Joined
Nov 3, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi all!!

Here’s my question:
If I have a data table with names for example:
A1: Mark

A2: Brian

A3: Luke



A20: John
A21:


Now let’s say A21 is blank. Is there a way for excel to automatically create a new sheet (tab on the bottom) titled “Tony” if I typed “Tony” into cell A21?



Not sure if it would be a formula or something else. Anything helps!!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
If you enter Alpha into Range ("A2") you want to create a new sheet named Alpha
Is that what you want? Or any other range in column 1
 
Upvote 0
If you enter Alpha into Range ("A2") you want to create a new sheet named Alpha
Is that what you want? Or any other range in column 1
Sorry, I don’t follow.

I think I would just want a macro or a way to automatically create a new sheet with the title of A21 but ONLY when I input the data in that cell. Not sure if that makes sense?
 
Upvote 0
Sorry, I don’t follow.

I think I would just want a macro or a way to automatically create a new sheet with the title of A21 but ONLY when I input the data in that cell. Not sure if that makes sense?
OK Only "A21"
 
Upvote 0
Try this: The script runs when you enter any value in Range("A21")
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  11/3/2022  7:24:46 PM  EST
If Target.Address = "$A$21" Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
On Error GoTo M
Dim ans As String
Dim sn As String
sn = ActiveSheet.Name
ans = Target.Value
Sheets.Add(After:=Sheets(Sheets.Count)).Name = ans
Application.Goto Sheets(sn).Range("A20")
End If
Exit Sub
M:
MsgBox ans & "   Is not a proper sheet name or sheet already exist"
ActiveSheet.Delete
Application.Goto Sheets(sn).Range("A20")
End Sub
 
Upvote 0
Solution
Try this: The script runs when you enter any value in Range("A21")
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  11/3/2022  7:24:46 PM  EST
If Target.Address = "$A$21" Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
On Error GoTo M
Dim ans As String
Dim sn As String
sn = ActiveSheet.Name
ans = Target.Value
Sheets.Add(After:=Sheets(Sheets.Count)).Name = ans
Application.Goto Sheets(sn).Range("A20")
End If
Exit Sub
M:
MsgBox ans & "   Is not a proper sheet name or sheet already exist"
ActiveSheet.Delete
Application.Goto Sheets(sn).Range("A20")
End Sub
Thank you!!
 
Upvote 0

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

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