+ Reply to Thread
Results 1 to 3 of 3

Using a Switch Case with logic operators on dates

  1. #1
    Registered User
    Join Date
    02-03-2016
    Location
    Mexico
    MS-Off Ver
    seven
    Posts
    6

    Cool Using a Switch Case with logic operators on dates

    Hello. I'm trying to find out the number of events from a table in each month of the year but my loop case doesn't seem to work. Even though the date fits in one of the cases it doesn't match and goes eventually to case else.
    I would appreciate any help with the syntax. Here is my code:

    Select Case data
    Case data >= #1/1/2016# And data <= #1/31/2016#
    months(0) = months(0) + 1
    Case data >= #2/1/2016# And data <= #2/29/2016#
    months(1) = months(1) + 1
    Case data >= #3/1/2016# And data <= #3/31/2016#
    months(2) = months(2) + 1
    Case data >= #4/1/2016# And data <= #4/30/2016#
    months(3) = months(3) + 1
    Case data >= #5/1/2016# And data <= #5/31/2016#
    months(4) = months(4) + 1
    Case data >= #6/1/2016# And data <= #6/30/2016#
    months(5) = months(5) + 1
    Case data >= #7/1/2016# And data <= #7/31/2016#
    months(6) = months(6) + 1
    Case data >= #8/1/2016# And data <= #8/31/2016#
    months(7) = months(7) + 1
    Case data >= #9/1/2016# And data <= #9/30/2016#
    months(8) = months(8) + 1
    Case data >= #10/1/2016# And data <= #10/30/2016#
    months(9) = months(9) + 1
    Case data >= #11/1/2016# And data <= #11/30/2016#
    months(10) = months(10) + 1
    Case data >= #12/1/2016# And data <= #12/31/2016#
    months(11) = months(11) + 1
    Case Else

    End Select

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Using a Switch Case with logic operators on dates

    You could use this ocde:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Using a Switch Case with logic operators on dates

    You could use this ocde:
    Please Login or Register  to view this content.
    You could also use this code:
    Please Login or Register  to view this content.
    Regards,
    Antonio

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Select Case vs Switch
    By tom.hogan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-17-2014, 02:31 PM
  2. [SOLVED] Sign Switch Logic and Subtotal
    By bbg22 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-01-2013, 03:45 PM
  3. Select Case Multiple Selector using Operators
    By vba_beginner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-18-2013, 04:08 PM
  4. VBA for CASE SELECT logic
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-05-2012, 10:23 AM
  5. Switch-case by Excel?
    By Jaymond Flurrie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2007, 08:39 PM
  6. Replies: 0
    Last Post: 07-13-2006, 03:10 AM
  7. Switch Case
    By HasExcelNoBrain in forum Excel General
    Replies: 0
    Last Post: 01-24-2005, 01:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1