+ Reply to Thread
Results 1 to 4 of 4

Filter/split data from a master sheet - Help its driving me nuts!

  1. #1
    Registered User
    Join Date
    01-10-2019
    Location
    England
    MS-Off Ver
    2016
    Posts
    2

    Filter/split data from a master sheet - Help its driving me nuts!

    Hi there,

    Really hoping someone can help me with this - it is driving my nuts.
    I am trying to split filtered data from a master sheet, to separate spreadsheets in the same workbook.
    When I use these two macros separately, they both do what I need.

    The first one filters:


    Sub Filter()
    ActiveSheet.Range("$A:$D").AutoFilter Field:=2, Criteria1:="No"
    End Sub

    The second one splits the remaining data out to different tabs, based on the column,


    Sub Depotsplit()
    Dim lr As Long
    Dim ws As Worksheet
    Dim vcol, i As Integer
    Dim icol As Long
    Dim myarr As Variant
    Dim title As String
    Dim titlerow As Integer
    vcol = 1
    Set ws = Sheets("Master")
    lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
    title = "A1:D1"
    titlerow = ws.Range(title).Cells(1).Row
    icol = ws.Columns.Count
    ws.Cells(1, icol) = "Unique"
    For i = 2 To lr
    On Error Resume Next
    If ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(ws.Cells(i, vcol), ws.Columns(icol), 0) = 0 Then
    ws.Cells(ws.Rows.Count, icol).End(xlUp).Offset(1) = ws.Cells(i, vcol)
    End If
    Next
    myarr = Application.WorksheetFunction.Transpose(ws.Columns(icol).SpecialCells(xlCellTypeConstants))
    ws.Columns(icol).Clear
    For i = 2 To UBound(myarr)
    ws.Range(title).AutoFilter Field:=vcol, Criteria1:=myarr(i) & ""
    If Not Evaluate("=ISREF('" & myarr(i) & "'!A1)") Then
    Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = myarr(i) & ""
    Else
    Sheets(myarr(i) & "").Move after:=Worksheets(Worksheets.Count)
    End If
    ws.Range("A" & titlerow & ":A" & lr).EntireRow.Copy Sheets(myarr(i) & "").Range("A1")
    Sheets(myarr(i) & "").Columns.AutoFit
    Next
    ws.AutoFilterMode = False
    ws.Activate
    End Sub

    The issue I am having, is that when i add the filter line in to the main script above, it will only split the first unique from the column with the filtered data, but not the others. I am finding it so confusing, as I got it to work once, but cant replicate it.
    For example, I want to split out football teams, IE, Man Utd, Liverpool, Arsenal, based on matches where they scored. However it is only populating the Man Utd tab.
    Hope this makes sense, can anyone shine a light on how to fix this?

    Appreciate you're help,

    Jason

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Filter/split data from a master sheet - Help its driving me nuts!

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    01-10-2019
    Location
    England
    MS-Off Ver
    2016
    Posts
    2

    Re: Filter/split data from a master sheet - Help its driving me nuts!

    Thanks for your reply, however this is still only pulling the one unique out.
    I really don't understand why it is not pulling the others out.

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,631

    Re: Filter/split data from a master sheet - Help its driving me nuts!

    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 6)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Is Excel 16.10 for Mac driving anyone else nuts?
    By CLSSY56 in forum The Water Cooler
    Replies: 3
    Last Post: 02-22-2018, 10:11 AM
  2. VLookup Help, driving me nuts
    By Sillybirds in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-23-2017, 07:03 AM
  3. [SOLVED] this is driving me nuts
    By silverdan7 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-25-2013, 01:10 AM
  4. + sign is driving me nuts
    By Flash3441 in forum Excel General
    Replies: 3
    Last Post: 06-29-2006, 04:00 PM
  5. Need Help, this is driving me nuts
    By heitorfjr in forum Excel General
    Replies: 2
    Last Post: 01-15-2006, 11:10 AM
  6. [SOLVED] question driving me nuts
    By Esaam in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 12-06-2005, 01:40 AM
  7. [SOLVED] Driving me nuts. Need more nested than 7
    By Stressed in forum Excel General
    Replies: 5
    Last Post: 04-12-2005, 02:06 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