Search code examples
excelvbahighlight

Highlight cells when its sum reached the value on another cell in Excel


I am new in VBA. I have this column. the first column is the period and the second is the list of payments of principal (see image). If I want to identify the period in which the payment has reached a certain amount, shall I use VBA or COnditional formatting?

I.e If i entered in a field $400, period 9 will be identified or rows 1 - 9 are highlighted. When you add the values(payments) from the periods from 1 - 9, period 9 is the first period in which the amount of $400 is reached or the first occurrence that $400 is less than the total amount of payments corresponding to its period.

I am aiming to highlight the rows from 1 - 9. or at least the period is identified.

enter image description here


Solution

  • I did this in Google Sheets. But the principle would be similar in Excel

    Here are the formulas enter image description here

    1. In C1, I enter your threshold.
    2. Column B contains the running total
    3. D contains 1 if the total in b exceeds threshold, as long as the row above for column D doesn't contain a 1 already.

    Next we have the conditional formatting: enter image description here

    So we know how to do it in Google Sheets you say..

    Next download it from Google Sheets as an Excel file, and open it in Excel This is how the Conditional Formatting was entered there (Office for Mac).

    enter image description here

    (Format > Conditional Formatting).

    In the future, you obviously wouldn't need Google Sheets, so you can follow this concept and Apply the conditional formatting directly in Excel.

    But I was able to illustrate with data and give a clickable example you can see that shows it working. You could literally download it into Excel your end and go.

    PS: Your question was very loosely worded/open to interpretation. I indicated the point at which the threshold was crossed. If you wanted to highlight the cells for every row up to and including the one where it was crossed, tweak the formulas for highlighting. Perhaps like this.. enter image description here

    etc.. etc...