Need help on nested select case statement

SKV

Active Member
Joined
Jan 7, 2009
Messages
257
can some one please help me identify the problem in the code below, its not working properly. It is just a simple nested select case code

Public Function Chadtest(dt As Date, scac As String) As Integer
Dim ct As Integer
MsgBox (scac)
Select Case scac
Case A
Select Case dt
Case #1/1/2009# To #1/31/2009#
ct = 2
Case #2/1/2009# To #2/28/2009#
ct = 4
Case Else
ct = 999
End Select
Case B
Select Case dt
Case #1/1/2009# To #1/31/2009#
ct = 3
Case #2/1/2009# To #2/28/2009#
ct = 5
Case Else
ct = 999
End Select
End Select

Chadtest = ct

End Function
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Greetings SKV,

You are passing 'scac' as a String, so Case(s) should be like:
Code:
Case "A"
    '....code
Case "B"
    '....etc

Hope this helps,

Mark
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

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