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
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 R = 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], 1, Header:=1
V = [R1].CurrentRegion
For R = 2 To UBound(V)
Worksheets.Add(, Worksheets(Worksheets.Count)).Name = V(R, 1)
[R2] = V(R, 1)
.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 » ! ◄ ◄
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 R = 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], 1, Header:=1
V = [R1].CurrentRegion
For R = 2 To UBound(V)
Worksheets.Add(, Worksheets(Worksheets.Count)).Name = V(R, 1)
[R2] = V(R, 1)
.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
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
.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
Bookmarks