ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filter Macro with Cell reference (https://www.excelbanter.com/excel-programming/365865-filter-macro-cell-reference.html)

chris100[_70_]

Filter Macro with Cell reference
 

Hi there,

I'm having an issue with recording a macro for custom filter with cell
references. The macro doesn't record a generic reference, just the
cell value at the time of recording. I looked loooong and hard for the
solution here, but i just can't find it. The closest i have to the
answer i found here (courtsey Tom Ogilvy):-

Selection.AutoFilter Field:=1, Criteria1:="=*" & Range("M13").Value _
& "*"

I tried playing around with the above but come unstuck when trying to
do a less than or equals to.

I desperately need help to this solution to finish off a project before
the weekend's out. Please, please please with extra whipped cream
help.

Chris

P.s could someone explain what the * element of the code is for?


--
chris100
------------------------------------------------------------------------
chris100's Profile: http://www.excelforum.com/member.php...o&userid=25166
View this thread: http://www.excelforum.com/showthread...hreadid=557087


Piotr Lipski

Filter Macro with Cell reference
 
Dnia Thu, 29 Jun 2006 14:50:30 -0500, chris100 napisał(a):

[...]
Selection.AutoFilter Field:=1, Criteria1:="=*" & Range("M13").Value _
& "*"

I tried playing around with the above but come unstuck when trying to
do a less than or equals to.


Selection.AutoFilter Field:=1, Criteria1:="<=" & Range("M13").Value

[...]
P.s could someone explain what the * element of the code is for?


Look at this code:
Criteria1:="=*" & Range("M13").Value & "*"

If M13 equals to, let's say, "xyz", then this line expands to:
Criteria1:="=*xyz*"

which means "show all records that CONTAIN xyz in field 1"

In the same way you could write:

Criteria1:="=" & Range("M13").Value & "*"

whicg means: all records BEGINNING with xyz in field 1

etc, etc...

--
PL

chris100[_72_]

Filter Macro with Cell reference
 

Thanks Piotr,

Meant to post and say that it worked. Appreciate the reply.

Chris


--
chris100
------------------------------------------------------------------------
chris100's Profile: http://www.excelforum.com/member.php...o&userid=25166
View this thread: http://www.excelforum.com/showthread...hreadid=557087



All times are GMT +1. The time now is 02:03 AM.

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