+ Reply to Thread
Results 1 to 1 of 1

Sort and extract data from one excel file into multiple excel files

  1. #1
    Registered User
    Join Date
    06-17-2008
    Posts
    1

    Sort and extract data from one excel file into multiple excel files

    Hi I have an excel file divided into many rows and columns here a sample data

    which is attached
    basically i want to sort through division and take all the division files and combine them into a separate excel worksheet

    so for example (raw date has 14 records)
    div 1 has 4 records (into a separate work sheet)
    div 2 has 10 records

    And i need to know how to program in vb in order to process this.

    Thankyou

    This is the code i have i'm able to extract all the divison numbers but cannot extract the rest of data

    Sub PagesByDescription()
    Dim rRange As Range, rCell As Range
    Dim wSheet As Worksheet
    Dim wSheetStart As Worksheet
    Dim strText As String

    Set wSheetStart = ActiveSheet
    wSheetStart.AutoFilterMode = False
    'Set a range variable to the correct item column
    Set rRange = Range("b2", Range("b65536").End(xlUp))

    'Delete any sheet called "UniqueList"
    'Turn off run time errors & delete alert
    On Error Resume Next
    Application.DisplayAlerts = False
    Worksheets("UniqueList").Delete

    'Add a sheet called "UniqueList"
    Worksheets.Add().Name = "UniqueList"

    'Filter the Set range so only a unique list is created
    With Worksheets("UniqueList")
    rRange.AdvancedFilter xlFilterCopy, , _
    Worksheets("UniqueList").Range("b2"), True

    'Set a range variable to the unique list, less the heading.
    Set rRange = .Range("a2", .Range("a65536").End(xlUp))
    End With

    On Error Resume Next
    With wSheetStart
    For Each rCell In rRange
    strText = rCell
    .Range("B2").AutoFilter 1, strText
    Worksheets(strText).Delete
    'Add a sheet named as content of rCell
    Worksheets.Add().Name = strText
    'Copy the visible filtered range _
    (default of Copy Method) and leave hidden rows
    .UsedRange.Copy Destination:=ActiveSheet.Range("B2")
    ActiveSheet.Cells.Columns.AutoFit
    Next rCell
    End With

    With wSheetStart
    .AutoFilterMode = False
    .Activate
    End With

    On Error GoTo 0
    Application.DisplayAlerts = True
    End Sub
    Attached Files Attached Files
    Last edited by fahadq; 06-17-2008 at 02:07 PM.

+ 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