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

Livin404

Active Member
Joined
Jan 7, 2019
Messages
392
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
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

davesexcel

Well-known Member
Joined
Feb 26, 2006
Messages
1,089
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
 
Solution

Livin404

Active Member
Joined
Jan 7, 2019
Messages
392
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,127,832
Messages
5,627,152
Members
416,224
Latest member
RichardHell

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
Top