+ Reply to Thread
Results 1 to 3 of 3

Data from one sheet to several based on category

  1. #1
    Andy Roberts
    Guest

    Data from one sheet to several based on category

    I have a spreadsheet that contains a control list of all volunteers on a
    given day for a not-for-profit. The first worksheeet has all individuals
    listed by area where they are volunteering. I have to provide the leader of
    each area with a list of his/her volunteers. The categories are in column
    "K." Both the number of volunteers and number of cateogories changes daily. I
    would like the macro to provide a separate tab for each category. I found
    some code to create separate sheets for each horizontal page break. But that
    doesn't help as the number of volunteers per area varies. But if someone
    could explain how to clear all existing page breaks and insert them based on
    change in category, I can make it work.

    Thanks for your help.

  2. #2
    Executor
    Guest

    Re: Data from one sheet to several based on category

    Hi Andy,

    You can use this to remove all present sheets and create a new serie.
    You must be sure to use this only when you are on the sheet with all
    info.

    Sub SheetForEachCategory()
    Dim wsTest As Worksheet
    Dim wsActive As Worksheet
    Dim sTemp As String

    Set wsActive = ActiveSheet
    ' remove all existing catagorysheets
    Application.DisplayAlerts = False
    For Each wsTest In ActiveWorkbook.Worksheets
    If wsTest.Name <> wsActive.Name Then
    wsTest.Delete
    End If
    Next
    Application.DisplayAlerts = True

    ' create new catagorysheets
    Range("K1").Select
    Do
    sTemp = ActiveCell.Value

    On Error Resume Next
    Set wsTest = Worksheets(sTemp)
    On Error GoTo 0
    If wsTest Is Nothing Then
    ActiveWorkbook.Worksheets.Add After:=wsActive
    ActiveSheet.Name = sTemp
    End If
    wsActive.Activate
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell)

    End Sub


    Hoop this helps


    Executor


  3. #3
    Andy Roberts
    Guest

    Re: Data from one sheet to several based on category

    Thank you.

    It works great.

    Andy

    "Executor" wrote:

    > Hi Andy,
    >
    > You can use this to remove all present sheets and create a new serie.
    > You must be sure to use this only when you are on the sheet with all
    > info.
    >
    > Sub SheetForEachCategory()
    > Dim wsTest As Worksheet
    > Dim wsActive As Worksheet
    > Dim sTemp As String
    >
    > Set wsActive = ActiveSheet
    > ' remove all existing catagorysheets
    > Application.DisplayAlerts = False
    > For Each wsTest In ActiveWorkbook.Worksheets
    > If wsTest.Name <> wsActive.Name Then
    > wsTest.Delete
    > End If
    > Next
    > Application.DisplayAlerts = True
    >
    > ' create new catagorysheets
    > Range("K1").Select
    > Do
    > sTemp = ActiveCell.Value
    >
    > On Error Resume Next
    > Set wsTest = Worksheets(sTemp)
    > On Error GoTo 0
    > If wsTest Is Nothing Then
    > ActiveWorkbook.Worksheets.Add After:=wsActive
    > ActiveSheet.Name = sTemp
    > End If
    > wsActive.Activate
    > ActiveCell.Offset(1, 0).Select
    > Loop Until IsEmpty(ActiveCell)
    >
    > End Sub
    >
    >
    > Hoop this helps
    >
    >
    > Executor
    >
    >


+ 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