LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default macro not giving right sum

I am trying to compare a value and then add that value to a cell. but
my sum is not coming right





Sub compare_price()
Dim i, j, k As Integer
Dim X, LR, LR1 As Long

LR = Worksheets("Expenses").Range("B" &
Rows.Count).End(xlUp).Offset(1, 0).Row
LR1 = Worksheets("Statement").Range("B" &
Rows.Count).End(xlUp).Offset(1, 0).Row
Set starta = Worksheets("Expenses").Range("B7")
Set startb = Worksheets("Statement").Range("A1")

'****set date format*****
For i = 1 To LR
starta.Offset(i, 0).Value = starta.Offset(i, 0).Value
starta.Offset(i, 0).NumberFormat = "mm/dd/yy;@"
Next i


starta.Offset(-2, 4) = 0
For i = 1 To 18
For j = 0 To LR1
If (starta.Offset(i, 4).Value = startb.Offset(j, 2).Value * (-1) And
starta.Offset(i, 0) = startb.Offset(j, 0)) Then
If starta.Offset(i, 4) < Empty Then
starta.Offset(i, 4).Interior.ColorIndex = 6
End If
'*******THIS LINE BELOW NEEDS CORRECTION*******
starta.Offset(-2, 4) = starta.Offset(-2, 4).Value + starta.Offset(i,
4).Value

End If
Next j
Next i

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
Giving Macro control to another workbook Trefor Excel Programming 3 July 25th 06 03:17 AM
Macro giving runtime error on one PC and not another Ingrid Excel Programming 2 September 13th 05 07:41 PM
Macro giving runtime error on one PC and not another Jim Thomlinson[_4_] Excel Programming 0 September 13th 05 05:45 PM
Why isn't this macro giving me proper results? Girish Excel Programming 3 September 9th 05 06:56 PM
Macro is giving me problems with sorting Charlene Dallos Excel Programming 3 September 2nd 03 07:02 PM


All times are GMT +1. The time now is 02:19 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"