![]() |
Using the Sum Function in VBA
Hello:
I am trying to use the sum function in a VBA module in an excel 2002 worksheet. When my code runs, it seems to not recognize the "Sum" function. Any suggestions as to why it is not being recognized would be appreciated. Is there a small line of code that I might be missing that would allow me to use this or any function? Thanks, Theresa |
Using the Sum Function in VBA
are you using the application.worksheetfunction.sum(1,2,3,4)
method. Keith www.kjtfs.co -- Message posted from http://www.ExcelForum.com |
Using the Sum Function in VBA
Hi Theresa,
There isn't a SUM function in VBA. You can use application.worksheetfunction.sum(1,2,3,4). Or do it the easy way. =1+2+3+4 -- John johnf 202 at hotmail dot com "Theresa Simpson" wrote in message ... | Hello: | | I am trying to use the sum function in a VBA module in an | excel 2002 worksheet. When my code runs, it seems to not | recognize the "Sum" function. Any suggestions as to why | it is not being recognized would be appreciated. Is | there a small line of code that I might be missing that | would allow me to use this or any function? | | Thanks, | | Theresa |
Using the Sum Function in VBA
No, I wasn't. Thank you very much. My problem now is
that it is summing incorrectly. I have looked at decimal places etc. There is nothing else that could be adding in that I can find anywhere. If I do a sum at the end of the column I get 1 total, the code produces another total. Scratching my head, totally baffled. !!!! -----Original Message----- are you using the application.worksheetfunction.sum (1,2,3,4) method. Keith www.kjtfs.com --- Message posted from http://www.ExcelForum.com/ . |
Not Adding Correctly!
No, I wasn't. Thank you very much. My problem now is
that it is summing incorrectly. I have looked at decimal places etc. There is nothing else that could be adding in that I can find anywhere. If I do a sum at the end of the column I get 1 total, the code produces another total. Scratching my head, totally baffled. !!!! -----Original Message----- are you using the application.worksheetfunction.sum (1,2,3,4) method. Keith www.kjtfs.com --- Message posted from http://www.ExcelForum.com/ . |
Not Adding Correctly!
Theresa,
Try to gather more information on the problem. Start by summing just one value and compare. Then two, then three etc until you identify the cells which are contributing to the problem. Rob "Theresa Simpson" wrote in message ... No, I wasn't. Thank you very much. My problem now is that it is summing incorrectly. I have looked at decimal places etc. There is nothing else that could be adding in that I can find anywhere. If I do a sum at the end of the column I get 1 total, the code produces another total. Scratching my head, totally baffled. !!!! -----Original Message----- are you using the application.worksheetfunction.sum (1,2,3,4) method. Keith www.kjtfs.com --- Message posted from http://www.ExcelForum.com/ . |
Using the Sum Function in VBA
I suggest setting up a loop that goes thru each cell and displays the
value in the cell you are adding, like a msgbox or just use a watch variable... See what the cells have in them you are adding then add them on a calculator. That should put you on the track as to what VBA is doing also make sure the variable you are using to store the sum in declared as in dim dblMySum as double and dblMySum = 0 . Hope that gets you closer to your answer. Keith www.kjtfs.com --- Message posted from http://www.ExcelForum.com/ |
Not Adding Correctly!
Hi Theresa
You mentioned looking at decimals. Have you checked whether you've declared all your 'to-be-summed' and your sum variables as Single or Double SuperJas. |
All times are GMT +1. The time now is 05:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com