Adding a row immediately following a "true" statement

  • Thread starter Thread starter Robb
  • Start date Start date
R

Robb

I need to add a row (keeping the format above) immediately following a 'true'
statement. I.e. if column k="C","R","RB" or "P", add row replacing
"C","R","RB" or "P" with "S".

I am trying to develop a spreadsheet to handling our invoicing for a
specific customer. Each of the above product codes needs an "S" line (for
shipping cost)
 
Here's some code

Public Sub ProcessData()
Dim i As Long
Dim LastRow As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
For i = LastRow To 1 Step -1

If .Cells(i, "K").Value2 = "C" Or .Cells(i, "K").Value2 = "R" Or
_
.Cells(i, "K").Value2 = "RB" Or .Cells(i, "K").Value2 = "P"
Then

.Rows(i + 1).Insert
.Cells(i + 1, "K").Value = "S"
End If
Next i
End With

End Sub

HTH

Bob
 
Back
Top