Consulting

Results 1 to 6 of 6

Thread: sum only red fonts

  1. #1
    VBAX Regular
    Joined
    Oct 2020
    Posts
    24
    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 p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,872
    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
    Everyone: 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
    24
    Location
    I copy to modul.
    on sheet copy formula, but give me false name.
    why?

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,872
    Works here:
    2020-11-26_124528.png
    Attached Files Attached Files
    p45cal
    Everyone: 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 Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    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
    24
    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
  •