Excel Advanced Filter - Macro - issue with finding the last cell

Clint123

New Member
Joined
Sep 18, 2013
Messages
10
Hi All,

First time using this forum so welcome all.

Just a question with my "Excel Advanced Filter - Macro" as below. Everything works fine

Issue: is the Range and that it changes "A4" will always be the first cell, however it may go from "A4:A6" or "A4:A333". Therefore, I need the Macro to take the last field etc.

MultipleSKU Macro
'
Sheets("EMEA - 12mth DEMD").Cells.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("A4:A12"), CopyToRange:=Range("F2:U2"), Unique:= _
False

End Sub

Thanks if anyone can help
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Which range are you referring to?

Is it the criteria range?

If it is which worksheet is it on?
 
Upvote 0
Yes, its the Criteria range which changes.

It is on worksheet "Multiple SKU's"

As mentioned however that the Macro currently works fine, just doesnt re-calculate then the range changes...
 
Upvote 0
Perhaps.
Code:
With ("Multiple SKU's")
     Sheets("EMEA - 12mth DEMD").Cells.AdvancedFilter Action:=xlFilterCopy, _
          CriteriaRange:=.Range("A4" & .Range("A" & Rows.Count).End(xlUp)), CopyToRange:=Range("F2:U2"), Unique:= False
End With

By the way, are you really filtering the entire 'EMEA - 12mth DEMD' sheet?
 
Upvote 0
Nope: still getting blocked at Range as I have highlighted below...

heets("EMEA - 12mth DEMD").Cells.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=.Range("A4" & .Range("A" & Rows.Count).End(xlUp)), CopyToRange:=Range("F2:U2"), Unique:=False

By the way, are you really filtering the entire 'EMEA - 12mth DEMD' sheet? I am filtering all the records within (so approx. 17 Accross and 10,000 down).
 
Upvote 0
What do you mean 'blocked'?

If you are only filtering that range why not limit the filter to that range?
 
Upvote 0
Did you use the code I posted, including the With part?
 
Upvote 0
Yep, below is what the VBA string now looks like. Still doesnt work unfortunately...New error "Compile Error: With object must be user-defined type, Object, or Variant.

Sub MultipleSKU()
'
' MultipleSKU Macro
'


'
With ("Multiple SKU's")
Sheets("EMEA - 12mth DEMD").Cells.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=.Range("A4" & .Range("A" & Rows.Count).End(xlUp)), CopyToRange:=Range("F2:U2"), Unique:=False
End With


End Sub

Thoughts???:)
 
Upvote 0
Oops, forgot Worksheets which is kind of important.:)
Code:
Sub MultipleSKU()
 '
 ' MultipleSKU Macro
 '


 '
 With Worksheets("Multiple SKU's")
    Sheets("EMEA - 12mth DEMD").Cells.AdvancedFilter Action:=xlFilterCopy, _
             CriteriaRange:=.Range("A4" & .Range("A" & Rows.Count).End(xlUp)), CopyToRange:=Range("F2:U2"), Unique:=False
 End With


 End Sub
 
Upvote 0

Forum statistics

Threads
1,215,539
Messages
6,125,403
Members
449,222
Latest member
taner zz

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