How to create in VBA array with name of sheets that are cell values and move data accordingly

ArtyS20

New Member
Joined
Oct 1, 2020
Messages
12
Office Version
  1. 2016
Platform
  1. Windows
I have sales representatives data in a workbook in a "Summary" tab. Each rep has a row of data. I want each rep to have its own sheet. Each sheet will only show data for each specific person and name the sheet as the person. Number of reps varies. At the end i want to have "Summary" tab with all data, and "Rep1", "Rep2", etc. with only their own data.

Thanks
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
In which column are the rep names? Does each rep have more than one row of data?
 
Upvote 0
In which column are the rep names? Does each rep have more than one row of data?

Column G and each rep will only have one row. Number or reps varies all the time though

Thanks
 
Upvote 0
Try:
VBA Code:
Sub createSheets()
    Application.ScreenUpdating = False
    Dim rep As Range
    For Each rep In Range("G2", Range("G" & Rows.Count).End(xlUp))
        rep.EntireRow.Copy
        If Not Evaluate("isref('" & rep.Value & "'!A1)") Then
          Sheets.Add(After:=Sheets(Sheets.Count)).Name = rep
          Range("A1").PasteSpecial
       End If
    Next rep
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Try:
VBA Code:
Sub createSheets()
    Application.ScreenUpdating = False
    Dim rep As Range
    For Each rep In Range("G2", Range("G" & Rows.Count).End(xlUp))
        rep.EntireRow.Copy
        If Not Evaluate("isref('" & rep.Value & "'!A1)") Then
          Sheets.Add(After:=Sheets(Sheets.Count)).Name = rep
          Range("A1").PasteSpecial
       End If
    Next rep
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
Perfect, thanks much!
 
Upvote 0
You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,539
Members
449,038
Latest member
Guest1337

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