I am using vba to export data into an Excel spreadsheet that sorts that data in column "B". I then insert 2 rows after each group. Out of those 2 rows I want to insert a Specific value into the the empty row inserted under each group in Column "B". Then insert 2 formulas in the same row but 1 in column "C" and the other in column "D".
Here is my code that inserts 2 rows with the help from firefytr.
With Sheets("All Loans")
LastRow = 3
For x = .Range("B65536").End(xlUp).Row To LastRow Step -1
If .Range("B" & x) <> .Range("B" & x - 1) Then Cells(x, 2).Resize(2, 1).EntireRow.Insert
Next x
End With
Here is the code I am working with to insert the first value.
Private Sub CommandButton1_Click()
Dim LastRow As Long, x As Long
With Sheets("All Loans")
LastRow = 3
For x = .Range("B65536").End(xlUp).Row To LastRow Step -1
If .Range("B" & x) <> .Range("B" & x - 1) Then _
Cells(x, "B").Value = "Totals:" & Cells(x, "B").Value
Next x
End With
End Sub
This code works but gives me an extra "Totals" for each group.
Thanks for the help,
Glenn