# Sum Of MAXROW, MAXCOL

How can i get the sum of Maxrow, maxcol  that includes up to 6 digits?
example: 4.456780
5.890900
--------------
sum       10.347680

my code below will not include the 3 to 5 digits.

``````Private Function TotalAmount() As Double
Dim PRICE As Double, QTY As Double, Amt As Double
On Error Resume Next
PRICE = 0
For MAXROW = x.LowerBound(1) To x.UpperBound(1)
For MAXCOL = x.LowerBound(2) To x.UpperBound(2)
Select Case MAXCOL
Case 7
QTY = x(MAXROW, MAXCOL)
Case 12
Amt = x(MAXROW, MAXCOL)
PRICE = PRICE + QTY * Amt
End Select
Next MAXCOL
Next MAXROW
TotalAmount = Format(PRICE, "#,###,##0.00##")
End Functio
``````
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Not sure, what you are asking.
You have the format command on line 16 which is truncating the digits.
>>TotalAmount = Format(PRICE, "#,###,##0.00##")
hope this helps.
0

Author Commented:
sorry but i could not explain very well,
My problem is that ... the result of the (TotalAmount) will round off up to two digits only.
and when i calculate, using the calculator there is a difference

example

amt is (15.582291)  *  qty (1)   then the result of my  TotalAmount is only 15.58

i want to get the TotalAmount 15.582291 as this is a original

the result would be 15.582291 not 15.80

0

Commented:
Then, remove the format command.
Try this.
``````Private Function TotalAmount() As Double
Dim PRICE As Double, QTY As Double, Amt As Double
On Error Resume Next
PRICE = 0
For MAXROW = x.LowerBound(1) To x.UpperBound(1)
For MAXCOL = x.LowerBound(2) To x.UpperBound(2)
Select Case MAXCOL
Case 7
QTY = x(MAXROW, MAXCOL)
Case 12
Amt = x(MAXROW, MAXCOL)
PRICE = PRICE + QTY * Amt
End Select
Next MAXCOL
Next MAXROW
TotalAmount = PRICE
End Function
``````
0

Author Commented:
Hi! i tried it but still the same.. i add
text1.text  = Format(Price, "#,###,##0.0000")   because i want the result to display in text1.text
but the display is 15.5800 instead of 15.582291

I  want to display the entire number of 15.582291 in the textbox...

My qty is 1 and my amt is 15.582291
I hope you can understand my example. Thanks...!!

0

Commented:
>>text1.text  = Format(Price, "#,###,##0.0000")

Give this,

text1.text  = Price
0

Author Commented:
Hi!,
I did it and the result is still  15.58
My problem is to get the sum total of case 12
under the row, the result is displayed as 15.582291 but  when i execute to display to textbox the result would be 15.58

Do i need to re-construct my questions? because i do believed that my question is not understandable because i myself got difficulties  on how to deliver this question very well.
but i'm willing to re-construct it. Thanks!!!
0

Commented:
Whereever you have given the Format(), remove that and see.

Also, check the runtime values in the debugger to see where exactly the value is getting round off.

Let me know if you need further help.
0

Experts Exchange Solution brought to you by ConnectWise

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
I tried to remove the all (Format()) and finally i found out the problems..
I really thank you   cyberwebservice, now i can to continue my project...
thanks so much!! More power to you...
0

Commented: