Question Details

No question body available.

Tags

excel vba

Answers (1)

March 18, 2026 Score: 1 Rep: 7,627 Quality: Low Completeness: 60%

The below code uses 2 counters, one for the rows of Sheet2 and one for the column G on Sheet1, where the system names take place.
The Do While loop checks if the consecutive cell in Sheet2 Column A are not empty, and does the insertion.

Sub SystemName()

'Dim LastRow, LRow As Long 'Dim Rng As Range 'Set Rng = Sheet2.Range("A3:A1500")

'On Error Resume Next

Dim pointer As Long, rowcnt As Long

pointer = 1 rowcnt = 2 With Sheet2 'LastRow = Cells(.Rows.Count, 1).End(xlUp).Row Do While IsEmpty(.Cells(rowcnt, 1)) True Or IsEmpty(.Cells(rowcnt + 1, 1)) True If IsEmpty(.Cells(rowcnt, 1)) = True Then .Cells(rowcnt, 1) = Sheet1.Range("G" & pointer).Value pointer = pointer + 1 .Cells(rowcnt, 1).EntireRow.Insert xlDown rowcnt = rowcnt + 1 End If rowcnt = rowcnt + 1 Loop End With

End Sub