View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
lpdarspe lpdarspe is offline
external usenet poster
 
Posts: 23
Default How do I read cell value and compare it with other cell in a c

Toppers-it did not quite work like it was supposed to. It created 2 blank
rows directly below the first row.

"Toppers" wrote:

Sub h()
lastrow = Cells(Rows.Count, "h").End(xlUp).Row
r = 1 ' <=== change start row of data
Do
n = Application.CountIf(Range("H:H"), Cells(r, "H"))
Cells(r + n, "A").Resize(2, 1).EntireRow.Insert
Cells(r + n, "I") = Application.Sum(Range(Cells(r, "h"), Cells(r + n - 1,
"H")))
r = r + n + 2
Loop Until r lastrow
Cells(r + n, "I") = Application.Sum(Range(Cells(r, "h"), Cells(r + n - 1,
"H")))

End Sub

"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?