ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autofilter contains vba strDept (https://www.excelbanter.com/excel-programming/282835-autofilter-contains-vba-strdept.html)

mark

Autofilter contains vba strDept
 
Help Please!

I'm sure this is an easy one, but I'm going around in
circles and failing badly!!

I want to do an autofilter which contains a string which
is selected from a userform combo, the code I have do so
far is: -

Sub FilterTaskChart()

Worksheets("Task Chart").Visible = True
Worksheets("Task Chart").Activate

frmDept.Show

Worksheets("Task Chart").Range("A2").AutoFilter _
Field:=1, _
Criteria1:= * & strDept & *, Operator _
:=xlAnd

Range("A1").Select

End Sub

It fails on the 'wildcard string wildcard' bit.

Can anyone assist with a solution, please?


Mark



RADO[_3_]

Autofilter contains vba strDept
 
put your wildcard expression in quotes:

"* & strDept & *"

RADO

"Mark" wrote in message
...
Help Please!

I'm sure this is an easy one, but I'm going around in
circles and failing badly!!

I want to do an autofilter which contains a string which
is selected from a userform combo, the code I have do so
far is: -

Sub FilterTaskChart()

Worksheets("Task Chart").Visible = True
Worksheets("Task Chart").Activate

frmDept.Show

Worksheets("Task Chart").Range("A2").AutoFilter _
Field:=1, _
Criteria1:= * & strDept & *, Operator _
:=xlAnd

Range("A1").Select

End Sub

It fails on the 'wildcard string wildcard' bit.

Can anyone assist with a solution, please?


Mark





mark

Autofilter contains vba strDept
 

RADO,

It now runs but doesn't filter anything out and when you
hover the cursor over the strDept it doesn't pick what it
contains, any other ideas?

Mark

-----Original Message-----
put your wildcard expression in quotes:

"* & strDept & *"

RADO

"Mark" wrote in

message
...
Help Please!

I'm sure this is an easy one, but I'm going around in
circles and failing badly!!

I want to do an autofilter which contains a string which
is selected from a userform combo, the code I have do so
far is: -

Sub FilterTaskChart()

Worksheets("Task Chart").Visible = True
Worksheets("Task Chart").Activate

frmDept.Show

Worksheets("Task Chart").Range("A2").AutoFilter _
Field:=1, _
Criteria1:= * & strDept & *, Operator _
:=xlAnd

Range("A1").Select

End Sub

It fails on the 'wildcard string wildcard' bit.

Can anyone assist with a solution, please?


Mark




.


No Name

Autofilter contains vba strDept
 
RADO,

Sorted it, thanks

I created another string which included the wildcards

Regards


Mark
-----Original Message-----

RADO,

It now runs but doesn't filter anything out and when you
hover the cursor over the strDept it doesn't pick what it
contains, any other ideas?

Mark

-----Original Message-----
put your wildcard expression in quotes:

"* & strDept & *"

RADO

"Mark" wrote in

message
...
Help Please!

I'm sure this is an easy one, but I'm going around in
circles and failing badly!!

I want to do an autofilter which contains a string

which
is selected from a userform combo, the code I have do

so
far is: -

Sub FilterTaskChart()

Worksheets("Task Chart").Visible = True
Worksheets("Task Chart").Activate

frmDept.Show

Worksheets("Task Chart").Range("A2").AutoFilter _
Field:=1, _
Criteria1:= * & strDept & *, Operator _
:=xlAnd

Range("A1").Select

End Sub

It fails on the 'wildcard string wildcard' bit.

Can anyone assist with a solution, please?


Mark




.

.


Tom Ogilvy

Autofilter contains vba strDept
 
That should be

Criteria1:= "*" & strDept & "*"

or
Criteria1:= "=*" & strDept & "*"

--
Regards,
Tom Ogilvy


"RADO" wrote in message
...
put your wildcard expression in quotes:

"* & strDept & *"

RADO

"Mark" wrote in message
...
Help Please!

I'm sure this is an easy one, but I'm going around in
circles and failing badly!!

I want to do an autofilter which contains a string which
is selected from a userform combo, the code I have do so
far is: -

Sub FilterTaskChart()

Worksheets("Task Chart").Visible = True
Worksheets("Task Chart").Activate

frmDept.Show

Worksheets("Task Chart").Range("A2").AutoFilter _
Field:=1, _
Criteria1:= * & strDept & *, Operator _
:=xlAnd

Range("A1").Select

End Sub

It fails on the 'wildcard string wildcard' bit.

Can anyone assist with a solution, please?


Mark








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

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