Excel/Color the Range of Cell when SUM reaches upto 100
QUESTION: Dear Jan,
I need your assistance in a very easy question.
How can we Highlight the range or cell when sum of that range reaches upto total '100' with the help of VBA Code?
You can see in below example the sum of A1 to A6 is 100. Now I color the range from A1 to A6 only.
Please provide your assistance on given question. I will be very thankful to you.
ANSWER: You could use a conditional format for this:
Select entire range
- Click conditional formatting, new rule
- Select "use a formula to determine which cells to format"
- enter this formula:
- set formatting.
---------- FOLLOW-UP ----------
QUESTION: Thanks for your reply...
But how can I do with VBA Code to accomplish this task.
How about this?
Dim oCell As Range
Dim dTot As Double
Range("A1:A100").Interior.Color = xlNone
For Each oCell In Range("A1:A100")
dTot = dTot + oCell.Value
If dTot = 100 Then
Range("A1", oCell).Interior.Color = vbRed
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here