View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Filter numbers with textbox using 123132*

Marc,

You need to get the syntax correct - the criteria string needs to be a valid equality statement

Criteria1:=Criteria1 & "*", _

should be

Criteria1:= "=" & Criteria1 & "*", _

etc.

HTH,
Bernie
MS Excel MVP


"Marc" wrote in message
ups.com...
Hi,

I have a problem with my code. I have made a userform with a textbox
and am trying to filter a set of numbers in a column.

I can get it to work when I write the exact number in the textbox
which
is also in the list with numbers. But I want to use the "*" asterisk.

Lets say if 123123 is in list and the textbox-value is 1. Then the
number should not be filtered/hidden.

Private Sub TextBoxWorkCenter_Change()
Dim Criteria1 As Double 'Tried As
String

Criteria1 = Val(TextBoxWorkCenter.Value) 'Tried using: & "*"
and without Val()

Worksheets("test1").Range("B6:B1000").AutoFilter _
field:=1, _
Criteria1:=Criteria1 & "*", _
Operator:=xlOr, _
Criteria2:="Center*", _
VisibleDropDown:=False
End Sub

Hope that somebody can help me????

Cheers

Marc