I'm trying to create a code that inserts a row before any row where the value in column M = 1. The code I tried using is as follows:
Code:
'THIS SHOULD INSERT A ROW BEFORE ALL ROWS
'WITH A VALUE OF 1 IN COLUMN M
Dim FoundCell As Range
Set FoundCell = Range("M:M").Find(what:=1)
Do Until FoundCell Is Nothing
FoundCell.EntireRow.Insert
Set FoundCell = Range("M:M").FindNext
Loop
The problem with this code (I think) is that it is inserting a row and then proceeding to search the next row and finding the row that was just shifted down. This macro runs out of control until I Ctrl Break. Any ideas how I could get it progress 1 row before it searches for the next row where M=1?
Thanks,
Josh