View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Randy Randy is offline
external usenet poster
 
Posts: 213
Default Help with my macro for two autofilters

I've written this macro to ask for input and then autofilter two columns
based on that input. The first part works fine but the second part steps on
the first autofilter. Would one of you gurus mind taking a look at my code
and let me know what's wrong? I'm thinking there must be one simple piece of
code that I'm missing.

Thanks!

Randy

Option Compare Text

Private Sub Workbook_Open()

Dim P As String
Dim B As String

B = ("")

P = InputBox("Please enter the size of your project: S for Small, M for
Medium, L for Large or Cancel for All.")


10 If (P) = "l" Or (P) = "m" Or (P) = "s" Then
Columns("C:C").Select
Selection.AutoFilter Field:=1, Criteria1:=(P)

Else: If (P) = "" Then GoTo 99
If (P) < "" Then
P = InputBox("Please enter a valid selection: S for Small, M
for Medium, L for Large or Cancel for All.")
GoTo 10
End If
End If

If (P) = "l" Or (P) = "m" Then
A = MsgBox("Is there a CIR for this project?", _
vbYesNo)

If A = vbNo Then
Columns("D:D").Select
Selection.AutoFilter Field:=1, Criteria1:=(B)

Else: GoTo 99
End If
End If

99 End Sub