Default Macro using Advanced Filter with Relative Reference

Marco73

New Member
Joined
Apr 13, 2017
Messages
2
Hello,

I am looking for a VBA sentence which make possible to copy a full data base which can change (Relative Reference) using the advance filter:

Sub MacroTest()
'
' MacroTest Macro
'
'
Workbooks("Other Excel file containing the Data Base.xlsx").Sheets("Data").Range("A3:EN3897"). _
AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"'Reference Sheet!Extract"), Unique:=False
Windows("Other Excel file containing the Data Base.xlsx").Activate
Windows("Reference Sheet.xlsx").Activate
End Sub

How can I change that: ("A3:EN3897"). to a relative reference type?

Thnak you for your help,
Marc
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
PS: Relative reference type:
Range("A3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

Thanks,
Marc
 
Upvote 0
Welcome to the board, try:
Code:
Sub MacroTest_v1

Dim LastRow as Long

With Workbooks("Other Excel file containing the Data Base.xlsx")
  With .Sheets("Data")
      LastRow = .Range("A" & Rows.Count).End(xlup).Row
      .Range("A3:EN" & LastRow).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("Reference Sheet!Extract"), _
         Unique:=False
  End With
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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