Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Blank Row

Status
Not open for further replies.

MyFlight

Technical User
Feb 4, 2002
193
Help I need a Macro that will insert a blank row in a worksheet. I receive a worksheet every week with a list of numbers between 100 and 1000 (and ohter data). I need to insert a blank row after each number in the spreadsheet (the numbers are not sequencial).

thanks
 
Assuming the data does not contain blanks rows in between data values prior to the addition of the new rows the following code will work. I included a delete rows macro as well.

Code:
Sub InsertRows()

Dim count As Integer
count = 1   'Starting row of data

While ThisWorkbook.Sheets(1).Cells(count, 1).Value <> ""    'Replace sheet name and column value as needed
    ThisWorkbook.Sheets(1).Rows(count + 1).insert xlShiftDown
    count = count + 2
Wend

End Sub

Sub DeleteRows()

Dim count As Integer
count = 1

While ThisWorkbook.Sheets(1).Cells(count, 1).Value <> ""
    ThisWorkbook.Sheets(1).Rows(count + 1).Delete xlShiftUp
    count = count + 1
Wend

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top