I'm learning Excel VBA programming, and I'm currently trying to get over an issue with how to sum up the values of a column if certain condition is satisfied.
I have one sheet which contains 10 columns in total i.e. from A to J. The Column "G" contain value of "9" but occurrence of this value is not fixed; it spreads randomly i.e. some cells contain null value (0) and some contains value 9 etc.
Column J contain a value at places only where there is a "9" present in Column "G", otherwise there is no value present in column J. Thus, Column J can contain a specific value only if there is a 9 present in a column G.
Now my question is , I want to add the values of the column "J" but I want to add only those block where there is a 9 present in Column G and the process continues till there is no empty cell encountered. Once , the macro found empty cell, it should again look for the value "9" in the column G and repeats the whole process until there is no more 9 present.
<tbody>
</tbody>
This is an example how my worksheet looks like, so there are cells in Column J which contains any value that can be any integer or decimal value or may be even 0 and there may be cells in column G and J which may contain no data.
<tbody>
</tbody>
As, there is no more 9 present in the column G, the macro should get stopped.
Please give your suggestion and advice how should I do this task.
Thanks for your help in advance.
I have one sheet which contains 10 columns in total i.e. from A to J. The Column "G" contain value of "9" but occurrence of this value is not fixed; it spreads randomly i.e. some cells contain null value (0) and some contains value 9 etc.
Column J contain a value at places only where there is a "9" present in Column "G", otherwise there is no value present in column J. Thus, Column J can contain a specific value only if there is a 9 present in a column G.
Now my question is , I want to add the values of the column "J" but I want to add only those block where there is a 9 present in Column G and the process continues till there is no empty cell encountered. Once , the macro found empty cell, it should again look for the value "9" in the column G and repeats the whole process until there is no more 9 present.
A | B | C | D | E | F | G | H | I | J |
9 | 1.2 | ||||||||
9 | 0 | ||||||||
9 | 1.563 | ||||||||
9 | 0 | ||||||||
<tbody>
</tbody>
This is an example how my worksheet looks like, so there are cells in Column J which contains any value that can be any integer or decimal value or may be even 0 and there may be cells in column G and J which may contain no data.
A | B | C | D | E | F | G | H | I | J |
9 | 1.2 | ||||||||
9 | 0 | ||||||||
9 | 1.563 | ||||||||
Sum = 2.763 | |||||||||
9 | 0 | ||||||||
Sum = 0 | |||||||||
9 | 5.4 | ||||||||
9 | 0 | ||||||||
9 | 0 | ||||||||
9 | 8.5 | ||||||||
Sum = 13.9 | |||||||||
<tbody>
</tbody>
As, there is no more 9 present in the column G, the macro should get stopped.
Please give your suggestion and advice how should I do this task.
Thanks for your help in advance.