Forum Discussion
Tommee
May 24, 2023Copper Contributor
Adding a column of cell numeric values to total within an excel macro.
Hello. I've tried to find on the web how to add cell numbers to a counter in an excel macro but can't find any examples. I've tried defining the total field: DIM integer, long, double, variable. I'...
Tommee
May 24, 2023Copper Contributor
Hello. Thank you for your answer.
I believe the DIM statement for the counter or accumulator might not be integer
but something else. Is this correct? Dim Totalacct As Integer
Also, the statement that is accumulating numbers isn't doing so:
The Totalacct variable is the accumulating the numbers in row J.
After the following: Cellrow).value or Cellrow).formula might
be incorrect.
Numbercell = Range("J" & Cellrow)
Totalacct = Totalacct + Numbercell
- Riny_van_EekelenMay 24, 2023Platinum Contributor
Tommee Can't really understand why you would want to do this with a macro but that's your choice. Pasted your code into a module and filled cells J5:J9 with the numbers you mentioned. Ran the code and the result of 1550 correctly shows in J105. See attached.