I need help writing VBA code to add a cell within a column based on a value in another column. Basically, if cell "K2" is greater than 0, I want to run a code that would insert a blank cell into that same row (cell "O2"), which would shift the current contents in O2 downward. I would like this code to run a loop to check every row consecutively, for a range.
I have already tried writing the code myself. However, instead of adding the cell at that row, it is adding a cell at the top of the column. This is the code I have so far:
loop
Sub AddCell()
Dim i As Range
For Each i In Range("K1:K10")
If i.Value > 0 Then
Range("K1:K10").Offset(0, 4).Insert Shift:=xlDown
End If
Next i
End Sub
Any help is appreciated! Thanks!
I have already tried writing the code myself. However, instead of adding the cell at that row, it is adding a cell at the top of the column. This is the code I have so far:
loop
Sub AddCell()
Dim i As Range
For Each i In Range("K1:K10")
If i.Value > 0 Then
Range("K1:K10").Offset(0, 4).Insert Shift:=xlDown
End If
Next i
End Sub
Any help is appreciated! Thanks!