+ Reply to Thread
Results 1 to 4 of 4

Macro to split workbook into several based on cell contents

Hybrid View

  1. #1
    rich@richdavies.com
    Guest

    Macro to split workbook into several based on cell contents

    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


  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    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 Sub

  3. #3
    Chip
    Guest

    RE: Macro to split workbook into several based on cell contents

    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.

    "rich@richdavies.com" wrote:

    > 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
    >
    >


  4. #4
    Ron de Bruin
    Guest

    Re: Macro to split workbook into several based on cell contents

    Try this
    http://www.rondebruin.nl/copy5.htm

    Try the workbook example

    --
    Regards Ron de Bruin
    http://www.rondebruin.nl



    <rich@richdavies.com> wrote in message news:1153389955.966884.4550@m73g2000cwd.googlegroups.com...
    > 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
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1