Hi,
I have a range of cells in a column which changes with new data.
Code selects the range to last cell in column with value +1.
Some of the cells in the range SUM the totals of the cells above (number of cells vary from 1 to many rows).
Code then finds first cell with "Sum" in formula, offsets to cell on left and inserts formula.
Loops back to do second pass.
That works fine.
Selects next Cell with "Sum" in Formula,offsets to cell on left and inserts formula.
That works fine.
Up to here there is no issue.
From here on though I cannot get the code to move down to the next "Sum" (there may be many) until the last cell in the Range (that was selected in the first place).
Clearly I have a syntax error and some missing code requirement!
Can anyone help?
Here is the code I have so far :
Sub LastCellInColumnOffsetInsert()
Dim foundCount As Long
Dim RR As Range
Set RR = Range("I1:I" & Range("I" & Rows.count).End(xlUp).Row)
RR.Select
Set dynamicRange = Range("I2").CurrentRegion
For Each cell In RR.Cells
With RR.Find(What:="sum", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate
ActiveCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(R[-1]C[-7]:R[-1]C[-7],"" "",""TOTAL"")"
End With
ActiveCell.Offset(1, 1).Activate
Cells.FindNext.Select
Next
End Sub
Bookmarks