Sunday, April 3, 2011

VB - Insert A Blank Row

This is child's play for all of you, but I don't know Visual Basic at all. How do I write a statement to insert a row between two rows in an Excel spreadsheet repeatedly? An example below:

F-3757 - GROF FILTER REWORKLIJN
F-3758 - POEDERAFSCHEIDER
F-3759 - FIJNFILTER
F-3760 - STOFILTER
F-3762 - AANZUIGFILTER
B-3771 - VENTILATOR STORTKOKER

to:

F-3758 - POEDERAFSCHEIDER

F-3759 - FIJNFILTER

F-3760 - STOFILTER

F-3762 - AANZUIGFILTER

B-3771 - VENTILATOR STORTKOKER
From stackoverflow
  • Sub Insert_Blank_Rows()  
       ''//Select last row in worksheet.
       Selection.End(xlDown).Select 
    
       Do Until ActiveCell.Row = 1 
           ''//Insert blank row.
           ActiveCell.EntireRow.Insert shift:=xlDown 
            ''//Move up one row.
           ActiveCell.Offset(-1, 0).Select 
        Loop 
     End Sub
    

    VBA Express shows an example how to accomplish it

    Erin Karschnik : Thank you so much! It worked perfectly.

0 comments:

Post a Comment