Good morning,I am trying to write a VBA script that inserts a row every time a cell value changes. The number of rows that contain cell value A, for example, is a dynamic number (e.g. there's no set number of rows). Below is my code:
This code inserts rows, but it inserts several hundreds of rows all together, and not everytime the cell value of interest changes.Any and all help is greatly appreciated!
Code:
myrows = WorksheetFunction.CountA(ws1.Range("A:A"))For i = 2 To myrows If Cells(i, 2) <> Cells(i + 1, 2) Then Cells(i, 2).Select ActiveCell.Offset(1).EntireRow.Insert End If Next i