ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to automatically insert a row if a cell meets a certain criter (https://www.excelbanter.com/excel-discussion-misc-queries/221315-how-automatically-insert-row-if-cell-meets-certain-criter.html)

gus

How to automatically insert a row if a cell meets a certain criter
 
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.

Luke M

How to automatically insert a row if a cell meets a certain criter
 
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
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Gus" wrote:

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.



All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com