Results 1 to 7 of 7

Parsing out file into multiple new files

Threaded View

ktalamantez Parsing out file into... 08-24-2013, 02:59 PM
JBeaucaire Re: Parsing out file into... 08-24-2013, 08:08 PM
kalak Re: Parsing out file into... 08-24-2013, 08:56 PM
JBeaucaire Re: Parsing out file into... 08-25-2013, 02:22 AM
perusjosh Re: Parsing out file into... 08-25-2013, 06:39 AM
kalak Re: Parsing out file into... 08-25-2013, 08:26 AM
perusjosh Re: Parsing out file into... 08-26-2013, 02:07 AM
  1. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Parsing out file into multiple new files

    1) Move the DATA you already have in column AA over to column W, or some other empty column. The macro is using column AA to create the unique list of Directors.

    2) In case you run the macro multiple times, probably a good idea to erase the named ranges the Advanced Filter creates.

    3) I've updated the code to no longer "select" sheets, unneeded.

    Option Explicit
    
    Sub ParseStudents()
    'JBeaucaire  (11/11/2009)
    'Based on column C, data is filtered to individual sheets
    'Creates sheets and sorts alphabetically in workbook
    Dim LR As Long, i As Long, MyArr
    Dim MyCount As Long, ws As Worksheet
    Application.ScreenUpdating = False
    
    Set ws = Sheets("Original")
    
    With ws
        On Error Resume Next
        .Range("Criteria").Name.Delete
        .Range("Extract").Name.Delete
        On Error GoTo 0
        .Columns("E:E").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=.Range("AA1"), Unique:=True
        .Columns("AA:AA").Sort Key1:=.Range("AA2"), Order1:=xlAscending, Header:=xlYes, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
        MyArr = Application.WorksheetFunction.Transpose(.Range("AA2:AA" & Rows.Count).SpecialCells(xlCellTypeConstants))
        
        .Range("AA:AA").Clear
        .Range("A1:K1").AutoFilter
        
        For i = 1 To UBound(MyArr)
            .Range("A1:K1").AutoFilter Field:=5, Criteria1:=MyArr(i)
            LR = .Range("A" & .Rows.Count).End(xlUp).Row
            If LR > 1 Then
                If Not Evaluate("=ISREF('" & MyArr(i) & "'!A1)") Then
                    Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = MyArr(i)
                Else
                    Sheets(MyArr(i)).Move After:=Sheets(Sheets.Count)
                    Sheets(MyArr(i)).Cells.Clear
                End If
                .Range("A1:K" & LR).Copy Sheets(MyArr(i)).Range("A1")
                .Range("A1:K1").AutoFilter Field:=1
                MyCount = MyCount + Sheets(MyArr(i)).Range("A" & Rows.Count).End(xlUp).Row - 1
                Sheets(MyArr(i)).Columns.AutoFit
            End If
        Next i
        .AutoFilterMode = False
        LR = .Range("A" & .Rows.Count).End(xlUp).Row - 1
        .Activate
    End With
    
    MsgBox "Rows with data: " & LR & vbLf & "Rows copied to other sheets: " & MyCount & vbLf & "Hope they match!!"
    Application.ScreenUpdating = True
    End Sub
    Last edited by JBeaucaire; 08-25-2013 at 02:17 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Import multiple jpg files in one file with file name in next cell
    By samyell in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2013, 07:58 AM
  2. Consolidate Data from Multiple Files (Different File Names) into a Master File
    By dspraveen_23 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-08-2012, 12:59 PM
  3. Replies: 0
    Last Post: 11-27-2012, 01:43 PM
  4. Parsing out file into multiple new files
    By CrystalNewb in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-17-2009, 02:34 PM
  5. Parsing Huge Files of Text
    By ajocius in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-06-2005, 08:45 PM

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