Static data plus filtered data to be copied to the first blank row of separate sheet

grf

Board Regular
Joined
Oct 30, 2004
Messages
70
Office Version
  1. 365
Morning experts,
On Sheet2 A1:J6 contains static data which will always be there. A6:J6 being the headings of my filtered data. The filtered data can occupy up to A7:J51 maximum.
I'm trying to find a way of copying the first 6 static rows of static data (A6:J6) plus the filtered data below it and copy it to the first blank row on sheet3. I'd be obliged if anyone could start me off.
Regards Graham
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Three questions:

(1)
By any chance are any cells in range A1:J6 merged. I suspect they are but if not, why would you have so many cells (6 in your case) comprise a field's single header label.

(2)
You wrote this:
"I'm trying to find a way of copying the first 6 static rows of static data (A6:J6)"
Did you really mean
I'm trying to find a way of copying the first 6 static rows of static data (A1:J6) or maybe something else.

(3)
Is what you want exactly what you say you want:
"I'm trying to find a way of copying the first 6 static rows of static data..."
You do not say you want the list filtered. Just copied presumably after it is filtered, which is fine but not a common request sans code including the filter action.
 
Upvote 0
Tom, thank you so much for your prompt reply. In answer to your questions:
1) No cells are merged
2) You are right, I did mean A1:J6
3) J7:J51 rows have been filtered and are therefore dynamic in their occupancy
And I should add that Sheet3 is completely blank at the moment.
Again, many thanks
Regards, Graham
 
Upvote 0
If the issue is as straightforward as that, you can run this, assuming you do not want to stack these recordsets on Sheet3 with those same 6 layers of field labels each time, but rather keep the destination range always starting on row 1 of Sheet3. If you want to stack each filtered execution below the previous one, post back to say that.

VBA Code:
Sub Test1()
With Sheets("Sheet3")
.Cells.Clear
Sheets("Sheet2").Range("A1").CurrentRegion.SpecialCells(12).Copy .Range("A1")
End With
End Sub
 
Upvote 0
Confirm if you want all 6 header rows every time, which would look redundant if they are always the same,
and
if you want the next recordset to be immediately below the previous recordset, or do you want an empty row between recordsets for readability.
 
Upvote 0
Yes please Tom, all 6 header rows every time with each recordset immediately below the previous one with an empty row between recordsets please.
 
Upvote 0
VBA Code:
Sub Test2()
Dim NextRow&
With Sheets("Sheet3")
If worksheetfunction.CountA(.Columns(1)) = 0 then
NextRow = 1
Else
NextRow = .Cells(.Rows.Count, 1).End(xlUp).Row + 2
End If
Sheets("Sheet2").Range("A1").CurrentRegion.SpecialCells(12).Copy .Cells(NextRow, 1)
End With
End Sub
 
Upvote 0
Solution
Thank you, I've loaded that in and when run it stops at, With Sheets("Sheet3"), and returns a Run-Time error 9 subscript out of Range
 
Upvote 0
Well, I coded Sheet3 because you said Sheet3 in your first post. So take a close look at what that destnation sheet tab is really named, and replace the Sheet3 that I have in the code based on your first explanation with whatever tab name that destination sheet is.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top