PDA

View Full Version : select a cell & fill a formula



lior03
08-03-2006, 08:11 AM
hello
i am trying to highlight a selection and make excel - on each empty cell ,where the cell above it do not have a formula- to sum the previous four row that meet
this criteria
Dim cell As Range
For Each cell In selection
With cell
If IsEmpty(cell) And Not cell.Offset(-1, 0).HasFormula = True Then
cell.FormulaR1C1 = "=SUM(R[-4]C:R[-1]C)"
End If
End With
Next
how do i force excel to sum a range from the last cell that do not have a formula to last one before the formula?
thanks

Bob Phillips
08-03-2006, 08:52 AM
You will overwrite whatever is in the cell, shouldn't it be in a different column?