Adding Blank Rows

  • Thread starter Thread starter JP SIngh
  • Start date Start date
J

JP SIngh

Hi All

Can someone please help me with this task?

I have worksheet where column G stores amounts and column F stores a text
value.

What I need to do is scan the whole column f and if the consective cells are
blank I need to find the corresponding total of the amount in the next
column.

For example

Column F Column G Column H
A 9.0
7.0
8.0
5.0 20 (7+8+5)
D 7.0
D 5.0
2.0
6.5
5.5 14.0(2+6.5+5.5)
C 60

I am after VBA solution

thanks
 
JP,

Sub JPSums()
Dim myArea As Range

For Each myArea In Range("F:F").SpecialCells(xlCellTypeBlanks).Areas
myArea.Cells(myArea.Cells.Count, 3).Value = _
Application.Sum(myArea.Offset(0, 1))
Next myArea

End Sub

HTH,
Bernie
MS Excel MVP
 
thanks a million


Bernie Deitrick said:
JP,

Sub JPSums()
Dim myArea As Range

For Each myArea In Range("F:F").SpecialCells(xlCellTypeBlanks).Areas
myArea.Cells(myArea.Cells.Count, 3).Value = _
Application.Sum(myArea.Offset(0, 1))
Next myArea

End Sub

HTH,
Bernie
MS Excel MVP
 
JP,

Sub JPSums2()
Dim myArea As Range
On Error Goto NoBlanks
For Each myArea In Range("F:F").SpecialCells(xlCellTypeBlanks).Areas
myArea.Cells(myArea.Cells.Count, 3).Value = _
Application.Sum(myArea.Offset(0, 1))
Next myArea
NoBlanks:
End Sub

HTH,
Bernie
MS Excel MVP
 
Back
Top