LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
pol pol is offline
external usenet poster
 
Posts: 129
Default Wrong result is coming while adding tow figures

Hi all,
I wrote the following function . But in some time the result is showing
wrong format. When VarSum gets value 185.42 and ValueSum gets -185.42 the
result should be 0.

VarSum = VarSum + ValueSum
0= 185 + - 185 . But some cases Excel shows the balance as
8.5265128E-14.

Please help. I given the function below.

Sub CashBookMacrosnew()
Dim VarSum As Double
Dim ValueSum As Double
Dim VarSumOld As Double
Dim totalsum As Double

lastrow = Range("B" & Rows.Count).End(xlUp).Row
currow = ActiveCell.Row
pre_row = ActiveCell.Row
Col_A = ""

For RowCount = 1 To lastrow
If RowCount 1 Then
pre_row = RowCount - 1
If Range("A" & RowCount) < "" Then
VarSumOld = VarSum
VarSum = Range("R" & RowCount)
Range("Y" & pre_row) = VarSumOld
Else

ValueSum = (Range("R" & RowCount) + Range("S" & RowCount) + Range("T" &
RowCount) + _
Range("U" & RowCount) + Range("V" & RowCount) + Range("W" & RowCount) + _
Range("X" & RowCount))
VarSum = VarSum + ValueSum
End If
End If


Next RowCount

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Min of formula equals coming up wrong txheart Excel Discussion (Misc queries) 2 April 25th 08 02:23 PM
excel result return wrong calcuation result garyww Excel Worksheet Functions 1 August 14th 06 11:14 AM
excel result return wrong calcuation result garyww Excel Worksheet Functions 0 August 14th 06 05:02 AM
excel result return wrong calcuation result garyww Excel Worksheet Functions 0 August 14th 06 05:02 AM
Summing a column, result coming up 0 thomasjefferson Excel Discussion (Misc queries) 4 September 4th 05 11:06 PM


All times are GMT +1. The time now is 09:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"