ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   filters and macros (https://www.excelbanter.com/excel-programming/337702-filters-macros.html)

Martin

filters and macros
 
Hello,
I do have a spreadsheet, where I do have created auto filter.
When I manually set the custom autofilter logic, the correct data will be
filtered.

Now I recorded a macro, which sets the autofilter, copys some subtotal
results and then sets some other filters, where it does the same.

=============
Macro
=============
Selection.AutoFilter Field:=13, Criteria1:="0,5", Operator:=xlAnd, _
Criteria2:="<=1"
Range("T1").Select
Application.CutCopyMode = False
Selection.Copy
Range("AP2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("U1").Select
Application.CutCopyMode = False
Selection.Copy
Range("AP3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
==================

When I now run the filter, no rows will be selected.

If I go into debug mode and set a breck point after the first cut function,
I can see that the filter was set by the macro, but not activated.

Any idear what when wrong in the recording?

Norman Jones

filters and macros
 
Hi Martin,

I ran your macro on data designed to mimic your autofilter range and, once
I had changed the first criterion from 0,5 to 0.5 (comma === dot/drop) to
accord with my local settings, it filtered my data as expected.

---
Regards,
Norman



"Martin" wrote in message
...
Hello,
I do have a spreadsheet, where I do have created auto filter.
When I manually set the custom autofilter logic, the correct data will be
filtered.

Now I recorded a macro, which sets the autofilter, copys some subtotal
results and then sets some other filters, where it does the same.

=============
Macro
=============
Selection.AutoFilter Field:=13, Criteria1:="0,5", Operator:=xlAnd, _
Criteria2:="<=1"
Range("T1").Select
Application.CutCopyMode = False
Selection.Copy
Range("AP2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("U1").Select
Application.CutCopyMode = False
Selection.Copy
Range("AP3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
==================

When I now run the filter, no rows will be selected.

If I go into debug mode and set a breck point after the first cut
function,
I can see that the filter was set by the macro, but not activated.

Any idear what when wrong in the recording?




Norman Jones

filters and macros
 
Hi Martin,

(comma === dot/drop)


was intended as:

(comma === dot / stop)

---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Martin,

I ran your macro on data designed to mimic your autofilter range and,
once I had changed the first criterion from 0,5 to 0.5 (comma ===
dot/drop) to accord with my local settings, it filtered my data as
expected.

---
Regards,
Norman



"Martin" wrote in message
...
Hello,
I do have a spreadsheet, where I do have created auto filter.
When I manually set the custom autofilter logic, the correct data will be
filtered.

Now I recorded a macro, which sets the autofilter, copys some subtotal
results and then sets some other filters, where it does the same.

=============
Macro
=============
Selection.AutoFilter Field:=13, Criteria1:="0,5", Operator:=xlAnd, _
Criteria2:="<=1"
Range("T1").Select
Application.CutCopyMode = False
Selection.Copy
Range("AP2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("U1").Select
Application.CutCopyMode = False
Selection.Copy
Range("AP3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
==================

When I now run the filter, no rows will be selected.

If I go into debug mode and set a breck point after the first cut
function,
I can see that the filter was set by the macro, but not activated.

Any idear what when wrong in the recording?






Martin

filters and macros
 
Norman,
even so my local number setting uses commas, I have changed the macro to dot
and now it works fine.

Thanks Martin


"Norman Jones" wrote:

Hi Martin,

I ran your macro on data designed to mimic your autofilter range and, once
I had changed the first criterion from 0,5 to 0.5 (comma === dot/drop) to
accord with my local settings, it filtered my data as expected.

---
Regards,
Norman



"Martin" wrote in message
...
Hello,
I do have a spreadsheet, where I do have created auto filter.
When I manually set the custom autofilter logic, the correct data will be
filtered.

Now I recorded a macro, which sets the autofilter, copys some subtotal
results and then sets some other filters, where it does the same.

=============
Macro
=============
Selection.AutoFilter Field:=13, Criteria1:="0,5", Operator:=xlAnd, _
Criteria2:="<=1"
Range("T1").Select
Application.CutCopyMode = False
Selection.Copy
Range("AP2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("U1").Select
Application.CutCopyMode = False
Selection.Copy
Range("AP3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
==================

When I now run the filter, no rows will be selected.

If I go into debug mode and set a breck point after the first cut
function,
I can see that the filter was set by the macro, but not activated.

Any idear what when wrong in the recording?





Norman Jones

filters and macros
 
Hi Martin,

even so my local number setting uses commas, I have changed the macro to
dot
and now it works fine.


Of course, VBA always uses US settings but translate the dot / stop to a
comma to accord with the user's local settings.

Something I knew and (often) forget!


---
Regards,
Norman



"Martin" wrote in message
...
Norman,
even so my local number setting uses commas, I have changed the macro to
dot
and now it works fine.

Thanks Martin


"Norman Jones" wrote:

Hi Martin,

I ran your macro on data designed to mimic your autofilter range and,
once
I had changed the first criterion from 0,5 to 0.5 (comma === dot/drop)
to
accord with my local settings, it filtered my data as expected.

---
Regards,
Norman



"Martin" wrote in message
...
Hello,
I do have a spreadsheet, where I do have created auto filter.
When I manually set the custom autofilter logic, the correct data will
be
filtered.

Now I recorded a macro, which sets the autofilter, copys some subtotal
results and then sets some other filters, where it does the same.

=============
Macro
=============
Selection.AutoFilter Field:=13, Criteria1:="0,5", Operator:=xlAnd,
_
Criteria2:="<=1"
Range("T1").Select
Application.CutCopyMode = False
Selection.Copy
Range("AP2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("U1").Select
Application.CutCopyMode = False
Selection.Copy
Range("AP3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
==================

When I now run the filter, no rows will be selected.

If I go into debug mode and set a breck point after the first cut
function,
I can see that the filter was set by the macro, but not activated.

Any idear what when wrong in the recording?








All times are GMT +1. The time now is 10:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com