![]() |
Sum Cells and assign to variable
I have a cell that needs to show the result of a formula.
Both the numerator and denominator are made up of a series of contiguous cells that are not subtotaled in their worksheets. I do not need the numerator and denominator values; just the result. In my VBA code, I tried setting variable Numerator=Sum ("K6:K12"), and I received an error that variable Sum wasn't defined. I know I can add each element to Numerator separately, but would prefer not to, if that's possible. Thanks for any suggestions. Kitty |
Sum Cells and assign to variable
One way:
Numerator = Application.WorksheetFunction.Sum(Range("K6:K12")) In article , "Kitty" wrote: I have a cell that needs to show the result of a formula. Both the numerator and denominator are made up of a series of contiguous cells that are not subtotaled in their worksheets. I do not need the numerator and denominator values; just the result. In my VBA code, I tried setting variable Numerator=Sum ("K6:K12"), and I received an error that variable Sum wasn't defined. I know I can add each element to Numerator separately, but would prefer not to, if that's possible. Thanks for any suggestions. Kitty |
Sum Cells and assign to variable
Perfect! Thank you so much for your help.
Kitty -----Original Message----- One way: Numerator = Application.WorksheetFunction.Sum(Range ("K6:K12")) In article , "Kitty" wrote: I have a cell that needs to show the result of a formula. Both the numerator and denominator are made up of a series of contiguous cells that are not subtotaled in their worksheets. I do not need the numerator and denominator values; just the result. In my VBA code, I tried setting variable Numerator=Sum ("K6:K12"), and I received an error that variable Sum wasn't defined. I know I can add each element to Numerator separately, but would prefer not to, if that's possible. Thanks for any suggestions. Kitty . |
All times are GMT +1. The time now is 08:31 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com