Consulting

Results 1 to 6 of 6

Thread: sum only red fonts

  1. #1
    VBAX Regular
    Joined
    Oct 2020
    Posts
    17
    Location

    sum only red fonts

    I have macro to merge 4 number for 1 worker. I have 82 workers in the worksheet.
    So, 1 worker have 4 diferent numbers.
    For this 4 numbers ( in 4 columns), 2 numbers are red (1 to all 4)

    1. I sum all numbers with sum function- is ok
    2. How I sum only red numbers font color vbred? for all 82 workers(2 rows)?

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,126
    User defined function:
    Function SumRed(rangeToSum)
    For Each cll In rangeToSum.Cells
      If cll.Font.Color = vbRed Then SR = SR + cll.Value
    Next cll
    SumRed = SR
    End Function
    Use on sheet:
    =SumRed(E5:G10)
    p45cal - - - - -This is my signature, it appears after all my posts. Below is not directed at anyone in particular - so don't take offence! - (You might guess why it's there though)
    If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Regular
    Joined
    Oct 2020
    Posts
    17
    Location
    I copy to modul.
    on sheet copy formula, but give me false name.
    why?

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,126
    Works here:
    2020-11-26_124528.png
    Attached Files Attached Files
    p45cal - - - - -This is my signature, it appears after all my posts. Below is not directed at anyone in particular - so don't take offence! - (You might guess why it's there though)
    If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    Moderator VBAX Wizard SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,315
    Location
    Conditional Formatting in use?
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  6. #6
    VBAX Regular
    Joined
    Oct 2020
    Posts
    17
    Location
    found and repair my mistake

Posting Permissions

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