+ Reply to Thread
Results 1 to 11 of 11

First line missing in auto filter to multiple sheets

  1. #1
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    First line missing in auto filter to multiple sheets

    Hi,

    Sample attached exactly represents original file so cell references to remain as is.
    All data is for sample reasons only except column 'I', this is exact.

    The Macro "sort" when run sorts all data on Report sheet in to all other sheets dependant on number in column 'I'

    For sake of ease there is a Macro "clearsheets" that will clear sheets 1-17 but leave data in Report sheet so you can test your code

    Issue I have is when Macro "sort" is run, it sorts all data from report sheet but misses out row 6
    So in sheet 1 you will see row 6&7
    All other sheets you will see rows 6-8

    But in report sheet you will see there should be 3 entries for sheets 1

    I have a feeling this is something to do with the autofilter being addressed to the first row I am trying to sort but I am unsure how to fix it

    Hope that all makes sense and thanks in advance for you help
    Attached Files Attached Files
    Last edited by ~TaC~; 01-20-2023 at 04:55 PM.

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,525

    Re: First line missing in auto filter to multiple sheets

    Something went wrong when attaching the workbook.

    Artik

  3. #3
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: First line missing in auto filter to multiple sheets

    Thanks for the heads-up. Guess I should have checked but it was late lol

    Now attached to OP

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi, try this !


    According to your attachment a starter VBA demonstration to paste only to the Sheet1 (Report) worksheet module :

    PHP Code: 
    Sub Demo1()
            
    Dim R&, V
        With Application
           
    .DisplayAlerts False
           
    .ScreenUpdating False
            
    For Worksheets.Count To Index 1 Step -1:  Worksheets(R).Delete:  Next
        With 
    [A5].CurrentRegion.Columns
           
    .Item(9).AdvancedFilter 2, , [R1], True
            
    [R1].CurrentRegion.Sort [R1], 1Header:=1
            V 
    = [R1].CurrentRegion
        
    For 2 To UBound(V)
            
    Worksheets.Add(, Worksheets(Worksheets.Count)).Name V(R1)
            [
    R2] = V(R1)
           .
    AdvancedFilter 1, [R1:R2]
            
    UsedRange.Resize(, .Count).Copy ActiveSheet.[A1]
        
    Next
        End With
            ShowAllData
            
    [Q1].CurrentRegion.Clear
           
    .DisplayAlerts True
           
    .ScreenUpdating True
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: First line missing in auto filter to multiple sheets


    Quote Originally Posted by ~TaC~ View Post
    I have a feeling this is something to do with the autofilter being addressed to the first row
    The reason why your .Offset(1) has no sense in the Copy codeline where .SpecialCells is useless …

  6. #6
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Hi, try this !

    Quote Originally Posted by Marc L View Post

    According to your attachment a starter VBA demonstration to paste only to the Sheet1 (Report) worksheet module :

    PHP Code: 
    Sub Demo1()
            
    Dim R&, V
        With Application
           
    .DisplayAlerts False
           
    .ScreenUpdating False
            
    For Worksheets.Count To Index 1 Step -1:  Worksheets(R).Delete:  Next
        With 
    [A5].CurrentRegion.Columns
           
    .Item(9).AdvancedFilter 2, , [R1], True
            
    [R1].CurrentRegion.Sort [R1], 1Header:=1
            V 
    = [R1].CurrentRegion
        
    For 2 To UBound(V)
            
    Worksheets.Add(, Worksheets(Worksheets.Count)).Name V(R1)
            [
    R2] = V(R1)
           .
    AdvancedFilter 1, [R1:R2]
            
    UsedRange.Resize(, .Count).Copy ActiveSheet.[A1]
        
    Next
        End With
            ShowAllData
            
    [Q1].CurrentRegion.Clear
           
    .DisplayAlerts True
           
    .ScreenUpdating True
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Thanks for reply, when run it comes up with Compile Error @ ShowAllData

  7. #7
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: First line missing in auto filter to multiple sheets

    Quote Originally Posted by Marc L View Post

    The reason why your .Offset(1) has no sense in the Copy codeline where .SpecialCells is useless …
    Thanks for reply, tried without Offset(1) and now sheet (1) has correct rows but all other sheets have an extra row

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: First line missing in auto filter to multiple sheets


    Quote Originally Posted by ~TaC~ View Post
    when run it comes up with Compile Error @ ShowAllData
    Your bad as you felt into the bad reader trap ! So delete the code module
    then well read the dark red direction before the code …

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: First line missing in auto filter to multiple sheets


    Quote Originally Posted by ~TaC~ View Post
    tried without Offset(1) and now sheet (1) has correct rows but all other sheets have an extra row
    So keep the Offset but delete the useless SpecialCells and start your range from row #5 rather than 6 …

  10. #10
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: First line missing in auto filter to multiple sheets

    So not being the greatest with VBA it took me awhile to work this out based on your reply @Marc L, but I wanted to do it without asking repeatedly so it would help me understand it better.

    It looks like I have it working with your suggestions Marc

    Please Login or Register  to view this content.
    .Range(.Cells(6, 9) - is data to look up
    With .Range("A5:L" & .Cells - filters from header row
    .Offset(1).Copy Sheets(ws).Range("A6") - copies to all sheets cell A6

    Correct me if I'm wrong but all working good

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Re: First line missing in auto filter to multiple sheets


    Quote Originally Posted by ~TaC~ View Post
    .Range(.Cells(6, 9) - is data to look up
    As it must start again from row #5 like you can check in VBA help and within my VBA demonstration …

+ 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. VBA - Auto Filter and make new sheets based on the filter values- Loop
    By Paul Cherian in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2017, 06:41 AM
  2. Replies: 5
    Last Post: 11-24-2014, 11:58 AM
  3. [SOLVED] Auto Filter Top Line copied to A400
    By BigTandthepc in forum Excel General
    Replies: 3
    Last Post: 06-27-2012, 10:50 AM
  4. Auto-filter and line in Excel VBA
    By CatherineLavoie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2011, 07:00 PM
  5. Filter, where certain line is missing
    By qingpool in forum Excel General
    Replies: 9
    Last Post: 02-16-2011, 02:45 AM
  6. Information missing in Auto Filter
    By Chemistification in forum Excel General
    Replies: 6
    Last Post: 10-01-2009, 06:48 AM
  7. Replies: 0
    Last Post: 06-04-2009, 02:06 PM

Tags for this Thread

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