Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Macro to add first row (titles) at every cchange in column P (Invoice Number) He

ID: 3564725 • Letter: M

Question

Macro to add first row (titles) at every cchange in column P (Invoice Number)

Helloo,,,

I need help writing a macro to add the first row, which are titles, at every change of column P, which are invoice numbers. I basically need to separate all invoices by inserting the titles in between without any spaces.

This is what I have:

This is what I need:

Thanks so much!

Macro to add first row (titles) at every cchange in column P (Invoice Number) Helloo,,, I need help writing a macro to add the first row, which are titles, at every change of column P, which are invoice numbers. I basically need to separate all invoices by inserting the titles in between without any spaces. This is what I have: This is what I have: Thanks so much!

Explanation / Answer

Hi,

Try this code.

Sub insertrowifnammechg()
Dim X As Long
For X = Cells(Rows.Count, "P").End(xlUp).Roow To 3 Step -1
    If Cells(X - 1, "P") <> Cells(X, "P") Then
        Rows(X).Insert
        Cells(1, 1).EntireRow.Copy Cells(X, 1)
    End If
Next X
End Subbb!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote