View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default How do I read cell value and compare it with other cell in a colum

Sub AAA()
Dim start As Range, rng As Range
Dim rngo As Range, i As Long
Set start = Range("H2")
i = 3
Do
Set rng = Cells(i, "H")
Set rngo = Cells(i - 1, "H")
If rng.Value < rngo.Value Then
rng.Resize(2).EntireRow.Insert
rngo.Offset(1, 1).Formula = "=Sum(" & _
Range(start, rngo).Offset(0, 1).Address & ")"
i = i + 2
Set start = Cells(i, "H")
End If
i = i + 1
If Cells(i, "H") = "" Then Exit Do
Loop
End Sub

worked for me. Test it on a copy of your data.

--
Regards,
Tom Ogilvy

"lpdarspe" wrote:

I want to create a macro in a spreadsheet that has been sorted in column H.
I want to put in 2 blank rows between different groups of data and then sum
up the value of that data in column J for that group in the 1st blank row
that was created.

I think this means reading the information in cell H2 and comparing cells
down the column until it does not equal the value in H2. I want to then
insert 2 blank rows and them sum up the values in column J for that group on
the 1st blank row that was created.

I want to retain the column H information and then compare it down the
column and repeat the process.

Does anyone have a sample I can use?