How do I create a new worksheet for each person in column A, and save it as their name with specific information included in each worksheet?

Justin_M

New Member
Joined
Feb 3, 2021
Messages
31
Office Version
  1. 2016
Platform
  1. Windows
I have a list of names in column A, and each person needs to have their own worksheet created with specific information from their row. How do I create a new worksheet for each person, and save it as their name?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Apparently there is an error with the row "
VBA Code:
sheet_name = Sheets("mySheet").Range("A1:A7").Cells(i, 1).Value
"

VBA Code:
Sub AddSheets()

Dim sheets_count As Integer
Dim sheet_name As String
Dim i As Integer

sheets_count = Range("A1:A7").Rows.Count

For i = 1 To sheet_count
  sheet_name = Sheets("mySheet").Range("A1:A7").Cells(i, 1).Value
  Worksheets.Add().Name = sheet_name
Next i

End Sub
 
Upvote 0
sheet_name = Sheets("mySheet").Range("A1:A7").Cells(i, 1).Value
If that truly is the error, see if this works an better:
VBA Code:
sheet_name = Sheets("mySheet").Range("A" & i).Value

If it still returns an error, let us know exactly what the error message is, and what the values in column A look like.

I would also change this line:
VBA Code:
sheets_count = Range("A1:A7").Rows.Count
to this:
VBA Code:
sheets_count = Cells(Rows.Count, "A").End(xlUp).Row
 
Upvote 0
Here's a simple script that has no error handling capability. Errors can occur if your list includes names already assigned to an existing sheet or names that use characters (like "/", ...) that are not acceptable in sheet names.
VBA Code:
Sub Justin()
Dim c As Range
For Each c In Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
    If Not IsEmpty(c) Then
        Worksheets.Add after:=Sheets(Sheets.Count)
        ActiveSheet.Name = c.Value
    End If
Next c
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,518
Messages
6,179,261
Members
452,901
Latest member
LisaGo

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