+ Reply to Thread
Results 1 to 2 of 2

SELECT CASE - Which Row am I on?

  1. #1
    Registered User
    Join Date
    06-16-2005
    Posts
    62

    Question SELECT CASE - Which Row am I on?

    Select Case is running in Range W8:W149 and is working.

    How do I determine what row I am on and add the number in Coulmn D to a variable?

    Column D contains the total sales (if any) for the day of the week. Some days have no sales other days have multiple sales.

    I am calculating the number of sales with this Select Case.

    I would like to know the total of all the sales by weekday.


    ------------------------------
    For Each rIncDay In Range("W8:W149") 'Need Last Row loop
    Select Case (rIncDay)
    '-------------------------
    'Days of the week
    Case "SUNDAY"
    iSun = iSun + 1
    Case "MONDAY"
    iMon = iMon + 1
    Case "TUESDAY"
    iTue = iTue + 1
    Case "WEDNESDAY"
    iWed = iWed + 1
    Case "THURSDAY"
    iThu = iThu + 1
    Case "FRIDAY"
    iFri = iFri + 1
    Case "SATURDAY"
    iSat = iSat + 1
    '-------------------------
    Case Else
    iOther = iOther + 1 'Error trap not in SELECT CASE
    '-------------------------
    End Select
    Next rIncDay
    ----------------------------

    Muchos Gracias, Mi Amigo!
    Craigm

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    rIncDay.row ' will return the row number



    dim sum_sales as variant
    sum_sales=0
    For Each rIncDay In Range("W8:W149") 'Need Last Row loop
    sum_sales=sum_sales+range("d" & rIncDay.row).value 'adding the d column
    Select Case (rIncDay)
    '-------------------------
    'Days of the week
    Case "SUNDAY"
    iSun = iSun + 1
    Case "MONDAY"
    iMon = iMon + 1
    Case "TUESDAY"
    iTue = iTue + 1
    Case "WEDNESDAY"
    iWed = iWed + 1
    Case "THURSDAY"
    iThu = iThu + 1
    Case "FRIDAY"
    iFri = iFri + 1
    Case "SATURDAY"
    iSat = iSat + 1
    '-------------------------
    Case Else
    iOther = iOther + 1 'Error trap not in SELECT CASE
    '-------------------------
    End Select
    Next rIncDay
    msgbox sum_sales

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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