Creat worksheets as per the list

Balajibenz

Board Regular
Joined
Nov 18, 2020
Messages
80
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I have a workbook where it got the the list as below in column B of sheet1. Can someone help me with VBA code to create each worksheet(in the same workbook) for each manager in the below list and worksheet name should be same as manager name. the list might change so whenever I run the code it should create new worksheets. thank you in advance.

Manager
Max
Alex
Harry
Sam
Sid
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi
What about
VBA Code:
Sub test()
    Dim a As Variant
    Dim i As Long
    Dim ws As Worksheet
    a = Cells(2, 2).Resize(Cells(Rows.Count, 2).End(xlUp).Row - 2)
    For i = 1 To UBound(a)
        Set ws = ThisWorkbook.Sheets.Add(After:= _
                                         ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
        ws.Name = a(i, 1)
    Next
End Sub
 
Upvote 0
Solution
Hi
What about
VBA Code:
Sub test()
    Dim a As Variant
    Dim i As Long
    Dim ws As Worksheet
    a = Cells(2, 2).Resize(Cells(Rows.Count, 2).End(xlUp).Row - 2)
    For i = 1 To UBound(a)
        Set ws = ThisWorkbook.Sheets.Add(After:= _
                                         ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
        ws.Name = a(i, 1)
    Next
End Sub
Hi Mate,

that works perfectly. can you also help me with the add on to the above request if you can please.

I have a sheet named as "Source" where there will be data. I want to insert a pivot table (in"A2") in each of the worksheets created above and source for pivot table will be the data in "Source" worksheet which will also have column named as "Manager" which needs to be added to the filters of the pivot table and the respective manager name should be filtered in that field. I can able to add other pivot fields that are required. Thanks again mate.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,199
Members
453,022
Latest member
RobertV1609

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