Creat worksheets as per the list

Balajibenz

New Member
Joined
Nov 18, 2020
Messages
49
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
 

Some videos you may like

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
918
Office Version
  1. 2013
Platform
  1. Windows
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
 
Solution

Balajibenz

New Member
Joined
Nov 18, 2020
Messages
49
Office Version
  1. 2013
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,850
Messages
5,598,455
Members
414,239
Latest member
xnanx

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
Top