Try this:
Code:Sub Test() Dim x As Long Application.ScreenUpdating = False For x = Range("A65536").End(xlUp).Row To 1 Step -1 Cells(x, 1).EntireRow.Resize(2).Insert Next x Application.ScreenUpdating = True End Sub
This is a discussion on Macro Looping within the Excel Questions forums, part of the Question Forums category; Is there a gerneral code for doing a procedure until a blank cell is reached. For example if i have ...
Is there a gerneral code for doing a procedure until a blank cell is reached.
For example if i have a column a of data in Column A and I want to insert 2 blank rows between each data point until it reaches a blank cell.
I have to do lots of this type of repetitive type of work and it would help greatly if I could use this code in different guises.
kind regards
Try this:
Code:Sub Test() Dim x As Long Application.ScreenUpdating = False For x = Range("A65536").End(xlUp).Row To 1 Step -1 Cells(x, 1).EntireRow.Resize(2).Insert Next x Application.ScreenUpdating = True End Sub
Thank you very much that works fine, I am right in saying the xlup part searches for the next occupied cell?
Range("A65536").End(xlUp)Originally Posted by matman
finds the last non-blank cell in column A. The code then loops backwards until it reaches row 1. The inserted rows are ignored because their row number is greater than the value of x.
Bookmarks