Consulting

Results 1 to 12 of 12

Thread: total Fridays in a range

  1. #1
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location

    total Fridays in a range

    vba returns total Fridays in A2:A6. eg A2:A6 all are Fridays, the value should be 5.
    Attached Files Attached Files

  2. #2
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    If you are trying to count the number of Fridays in that range use the array formula:

    =SUM((WEEKDAY(A2:A6)=6)*1)

    confirmed with CTRL+SHIFT+ENTER.
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

  3. #3
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location
    Quote Originally Posted by Teeroy View Post
    If you are trying to count the number of Fridays in that range use the array formula:

    =SUM((WEEKDAY(A2:A6)=6)*1)

    confirmed with CTRL+SHIFT+ENTER.
    The result as shown on Snap3.png is not I wanted.
    Attached Images Attached Images

  4. #4
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    What is the evaluated result? Only the formula is shown in the image.
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

  5. #5
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location

    total Fridays in a range

    I want: if SUM((WEEKDAY(A2:A6) = 5 then .........
    Attached Images Attached Images

  6. #6
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    =IF(SUM((WEEKDAY(A2:A6)=6)*1)=5,"Yes","No") CTRL+Shift+Enter
    Use the output as the test in your VBA
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

  7. #7
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location

    total Fridays in a range

    Quote Originally Posted by Teeroy View Post
    =IF(SUM((WEEKDAY(A2:A6)=6)*1)=5,"Yes","No") CTRL+Shift+Enter
    Use the output as the test in your VBA
    run macro but there is Compile error
    Attached Images Attached Images

  8. #8
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    A Basic course in VBA might be beneficial.

  9. #9
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    asdzxc, what I gave you was a worksheet formula (an array formula in fact as it required C-S-E), not VBA code. You put it in a worksheet then test the Value of the range where it is located as condition for any VBA code.
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

  10. #10
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Not clear if you're looking for a worksheet formula or a VBA solution to find number of Fridays in a range

    the worksheet formula must be 'Array Entered', that is instead of {Enter} you need to use Control+Shift+Enter instead

    You do NOT put the { .... } in yourself, Excel will do that when you do the Control+Shift+Enter

    Paul
    Attached Images Attached Images
    Last edited by Paul_Hossler; 10-02-2013 at 11:34 AM. Reason: Add note to NOT enter the {..}

  11. #11
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location
    stock data was downloaded. my macro can convert daily data into weekly data. if it is weekly data, I want conversion not to act.

  12. #12
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    asdzxc --


    Your Original request #1

    total Fridays in a range

    vba returns total Fridays in A2:A6. eg A2:A6 all are Fridays, the value should be 5.



    Latest post #11

    stock data was downloaded. my macro can convert daily data into weekly data. if it is weekly data, I want conversion not to act.


    I (for one) am extremely confused.

    Yout#1 refers to VBA, but the example uses worksheet functions

    My #10 is a simple worksheet formula to count the number of Fridays in a range, and based on your data returns the expected answer of 5

    What if anything does your #11 mean to the number of Fridays?????????????????????

    Paul

Posting Permissions

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