Macro to split workbook into several based on cell contents

R

rich

Hi,

I have a worksheet with all the sales data by salesperson for ten
branches. Column A is Branch Name, B is Sales Person, C is sales
figures.

I want to create a macro which splits this into ten workbooks, named by
branchname.


Can anyone suggest the easiest way ?



Rich
 
J

jetted

Hi

Would this work?
Sub create_worksheet()
branch = "Branch Name"
sale = "Sales Persons"
figur = "Sales Figures"

rowcount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
For i = 2 To rowcount
'Assuming the info is on sheet1, if not change the name
Sheets("sheet1").Activate
Range("a" & i).Select
w_name = ActiveCell.Value
Range("b" & i).Select
salep = ActiveCell.Value
Range("c" & i).Select
salef = ActiveCell.Value
Worksheets.Add
ActiveSheet.Name = w_name
ActiveSheet.Activate
Range("a1").Select
ActiveCell = branch
Range("a2").Select
ActiveCell = w_name
Range("b1").Select
ActiveCell = sale
Range("b2").Select
ActiveCell = salep
Range("c1").Select
ActiveCell = figur
Range("c2").Select
ActiveCell = salef

Next
'Assuming the info is on sheet1, if not change the name
Sheets("sheet1").Activate
End Su
 
C

Chip

I did this from a pivot table and used Show Pages. I then told Excel to copy
the page to a new workbook and save as sheet.name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top