How to automatically insert a row if a cell meets a certain criter

  • Thread starter Thread starter Gus
  • Start date Start date
G

Gus

I have a large amount of data with irregular patterns, and to perform an
additional amount of analysis, I need to insert a row under every time a
certain field is defined as a certain value (in this case FALSE). Is there
anyway I can do this without coding a full macro..ie with If functions and
Do/loops etc.

Cheers.
 
A simple macro will work, just change the array to match your criteria. Do
note that this doesn't check if the next row is blank (macro already ran).
One way to check might be to include ' And cell.offset(1,0).value = "" '
with your If statement.

Sub InsertRows()
For Each cell In Range("C1:C100")
If cell.Value = "FALSE" Then
cell.Offset(1, 0).EntireRow.Insert
End If
Next cell
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top