Can anyone tell me if it's possible to have 2 criteria and 2 different criteria ranges to sum data using a UDF.
Sample file attached.
Can anyone tell me if it's possible to have 2 criteria and 2 different criteria ranges to sum data using a UDF.
Sample file attached.
Assuming this definition:
where CellColor is criteria 1 and CoLetter is criteria 2Please Login or Register to view this content.
and
would return 50 in your example, then:Please Login or Register to view this content.
Please Login or Register to view this content.
I'm interested in starting a career working with VBA, if anyone knows of any opportunities!
You only gave an example, not a specification. So here is the specification based on your example:
Sum the numeric values in a range, including those values that have a given value in the same row immediately to the left of the sum range, and with a fill color that matches the color of a given cell.
Please Login or Register to view this content.
Thank you both for the quick response.
Working a treat!
Please note an important difference between the two solutions.
walruseggman's solution assumes that you are checking column A for the letter that you want to match. That is a good solution if that is your situation. Mine is slightly more general in that it will look to the immediate left of the range containing the data. If your letters are always in column A then walruseggman's code is a bit simpler.
Agreed, @6StringJazzer. On that note, if you do want to change the column where the company letters are, just change the 1 in Cells(myCell.Row, 1).Value to whatever you want. It's still a hard-coded column, but does offer you a degree of flexability.
@6StringJazzer: would you care to discuss your use of myCell.Parent instead of just Cells? I'd just never seen that used before.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks