Ill try that now...in response to your question though, i've retested that bit of code, and it doesn't add everything up a second time as i suggested. Instead it adds every line up correctly and it eventually reaches the correct total at somewhere around row 22, it then adds 0.60 to every remaining empty row up to row 50.
You have to specify within the program what the maximum row count will be (that what the 'For n = 1 To Amount.LineCount ' line refers to). I have it set to 50. It's a similar thing to the used row count in excel, even though excel recognises all the way down to row 60,000 or whatever.
EDIT - by the way, when i run that code you gave me in the previous post, i get the message "Type Mismatch ll"
< Message edited by Camus -- 2/11/2008 4:07:25 AM >
Ok, the problem is caused by the empty trailing lines returning "". Let's try this:
dblSum = 0.0 For n = 1 To Amount.LineCount sTmp = Trim( Amount.Line(n) ) If IsNumeric( sTmp ) Then On Error Resume Next dblTmp = CDbl(sTmp) If 0 <> Err.Number Then MsgBox Err.Description & " |" & sTmp & "|" dblTmp = 0.0 End If On Error GoTo 0 dblSum = dblSum + dblTmp End If Next MsgBox dblSum