Copy and paste the range two rows below the previously pasted range.

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings, I'm using the VBA with advance auto-filter, and it seems to be working great in copying and pasting to another worksheet. The thing is I have to rerun the auto-filter macro several times slightly different to get the multiple results I need. The macro below works fine, but for each subsequent macro I would need the deficiencies pasted two rows below the last pasted range. The macro I'm using to get the first one works perfect, I just don't want the new ones replacing the first one. Thank you,

VBA Code:
Sub Date_Filter_Copy()
Dim rgData As Range, rgCriteria As Range, rgOutput As Range

Set rgData = ThisWorkbook.Worksheets("Database").Range("A4").CurrentRegion
Set rgCriteria = ThisWorkbook.Worksheets("Database").Range("A1").CurrentRegion
Set rgOutput = ThisWorkbook.Worksheets("Deficiencies").Range("A1")

rgData.AdvancedFilter xlFilterCopy, rgCriteria, rgOutput

End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Set rgOutput = ThisWorkbook.Worksheets("Deficiencies").Range("A1")
Just the top of my head
VBA Code:
dim sh as worksheet
dim LstRw as long
set sh=sheets("Deficiencies")
with sh
lstrw=.cells(.rows.count,"A").end(xlup).row + 2
Set rgOutput=.range("A" & lstrw)
end with
 
Upvote 0
Solution
Thank you, I got it to work. Took be a few moments to get the syntax correct. I just combined the two, The following is what I used, Thank you.

VBA Code:
Sub Date_Filter_Copy3()
Dim rgData As Range, rgCriteria As Range, rgOutput As Range
Dim sh As Worksheet
Dim LstRw As Long
Set rgData = ThisWorkbook.Worksheets("Database").Range("A4").CurrentRegion
Set rgCriteria = ThisWorkbook.Worksheets("Database").Range("A1").CurrentRegion
Set rgOutput = ThisWorkbook.Worksheets("Deficiencies").Range("A1")
Set sh = Sheets("Deficiencies")
With sh
LstRw = .Cells(.Rows.Count, "A").End(xlUp).Row + 2
Set rgOutput = .Range("A" & LstRw)
rgData.AdvancedFilter xlFilterCopy, rgCriteria, rgOutput
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

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