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 eevery change in columnn P (Invoice Number) H

ID: 3564978 • Letter: M

Question

Macro to add first row (titles) at eevery change in columnn P (Invoice Number)

Hello,,,

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 eevery change in columnn P (Invoice Number) Hello,,, 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:

Explanation / Answer

Hi,

Try this codee...

Sub insertrowifnamechg()
Dim X As Long
For X = Cells(Rows.Count, "P").End(xlUp).Row To 3 Step -1
    If Cells(X - 1, "P") <> Cells(X, "P") Theen
        Rows(X).Inssert
        Cells(1, 1).EntireRow.Copy Cells(X, 1)
    End If
Next X
End Sub

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