Macro to create new supplier sheets for each new supplier

richardjshaffer

Board Regular
Joined
Oct 9, 2008
Messages
84
Please, hope someone can help.

What we are trying to achieve is a macro which creates a new worksheet for every unique supplier listed in the SUMMARY worksheet.

So the SUMMARY worksheet is populated which lots of data with many different suppliers listed down in column B, and the relevant data in the other columns - what the macro needs to do is use the TEMPLATE worksheet and create a new worksheet for each different supplier (with the worksheet created named by the supplier number) and the relevant fields in each new worksheet filled in.

I have an example file which just shows 1 worksheet created (F1111) for the only supplier mentioned in the SUMMARY worksheet, but there could be many different suppliers - I'm not sure how, how would I attach this file to my thread?

many thanks,

Richard
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi Richard,

I don't write or understand VBA so I cannot help you with code, sorry.

I use the following (which probably isn't perfect) to create copies of a Template based on the range of names in B2:B on sheet Lists.....

Code:
Sub CreateSheets()
Application.ScreenUpdating = False
    With Sheets("Lists")
        For a = 2 To .Cells(Rows.Count, 2).End(xlUp).Row
            sname = .Cells(a, 2).Value
            destsht = CStr(Format(sname, ""))
        On Error Resume Next
            If Not Worksheets(destsht).Name = destsht Then
                Sheets("Template").Copy After:=Sheets(Sheets.Count)
                Sheets("Template (2)").Name = destsht
            End If
            
        Next
    End With
Application.ScreenUpdating = True
End Sub

Sheet Template needs to be the last sheet tab on the right and all the sheet names created will appear to the right of your Template sheet.

Good luck.

Ak
 
Upvote 0
Thanks for your reply, though I think my example is a little more complex. Is there a way to post my excel example on the site for people to see and hopefully help?

thanks
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,756
Members
452,940
Latest member
rootytrip

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