Select Case Statements

UberFrank

Board Regular
Joined
Jul 8, 2010
Messages
51
Hi guys, can anyone explain why the following case statement isnt working? Intead of replacing ALL with * it just skips straight to the else statement and uses all.


Code:
Sub Macro1()
    Dim startdate As Long, enddate As Long, Client As String, Depot As String
 
    startdate = CLng(DateValue(Sheets("Reports & Archive").Range("B8")))
    enddate = CLng(DateValue(Sheets("Reports & Archive").Range("D8")))
 
    Select Case Sheets("Reports & Archive").Range("H8").Value
    Case "ALL"
    Client = "*"
    Case Else
    Client = Sheets("Reports & Archive").Range("H8").Value
    End Select
    Select Case Sheets("Reports & Archive").Range("F8").Value
    Case "ALL"
    Depot = "*"
    Case Else
    Depot = Sheets("Reports & Archive").Range("F8").Value
    End Select
 
 
    Sheets("Archived Escalations").Activate
 
    Sheets("Archived Escalations").Copy
    ChDir "[URL="file://\\888888888888888888888"]\\888888888888888888888[/URL]"
    ActiveWorkbook.SaveAs Filename:= _
        "[URL="file://\\88888888888888888888"]\\88888888888888888888[/URL]report.xls", FileFormat:= _
        xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
        , CreateBackup:=False
    ActiveSheet.Unprotect
    Range("B2:J2").Select
 
    Selection.AutoFilter Field:=1, Criteria1:=">=" & startdate, Operator:=xlAnd _
        , Criteria2:="<=" & enddate
 
    Selection.AutoFilter Field:=5, Criteria1:="" & Client
    Selection.AutoFilter Field:=6, Criteria1:="" & Depot
 
End Sub

Thanks in advance
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi Andrew,

Yes the cell does contain the text ALL. I have tested this and all works except that the custom filter serches for "All" instead of "*"

Thanks
 
Upvote 0
Thank you very much Ser, this has resolved the issue.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Much appreciated<o:p></o:p>
 
Upvote 0

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top