Not working. Its still doesn't insert a row
Not working yet.
I am trying to insert a row with this code, however, I think it's not inserting on certain rows because there is a blank empty cell (not a zero) and therefore the code just stops looking throughout the rest of the column.
So, as the code moves down thru the column and when it reaches a specific cell, I need it to do the following:
1.) If > 0, then insert one row below the number encountered
2.) Ignore all blank cells as well as it moves thru down the column.
** I want to move thru one column, inserting rows...then move thru the next column inserting more rows...etc, only when it encounters a number greater than zero (and not a blank cell).
Here is the code:
Sub InsertRows()
iRow = 3
Do Until Sheets("Heijunka Box Prep").Cells(iRow, 12) = ""
If Sheets("Heijunka Box Prep").Cells(iRow, 12) > 0 Then 'Greater than 0
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
iRow = iRow + 2 'ie there is now another row to skip
Else
iRow = iRow + 1
End If
Loop
iRow = 3
Do Until Sheets("Heijunka Box Prep").Cells(iRow, 13) = ""
If Sheets("Heijunka Box Prep").Cells(iRow, 13) > 0 Then 'Greater than 0
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
iRow = iRow + 2 'ie there is now another row to skip
Else
iRow = iRow + 1
End If
Loop
iRow = 3
Do Until Sheets("Heijunka Box Prep").Cells(iRow, 14) = ""
If Sheets("Heijunka Box Prep").Cells(iRow, 14) > 0 Then 'Greater than 0
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
iRow = iRow + 2 'ie there is now another row to skip
Else
iRow = iRow + 1
End If
Loop
iRow = 3
Do Until Sheets("Heijunka Box Prep").Cells(iRow, 15) = ""
If Sheets("Heijunka Box Prep").Cells(iRow, 15) > 0 Then 'Greater than 0
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
iRow = iRow + 2 'ie there is now another row to skip
Else
iRow = iRow + 1
End If
Loop
iRow = 3
Do Until Sheets("Heijunka Box Prep").Cells(iRow, 16) = ""
If Sheets("Heijunka Box Prep").Cells(iRow, 16) > 0 Then 'Greater than 0
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
Sheets("Heijunka Box Prep").Rows(iRow + 1).Insert 'Insert a whole row
iRow = iRow + 2 'ie there is now another row to skip
Else
iRow = iRow + 1
End If
Loop
Any suggestions??
Thanks,
Jim