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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy and paste rows between sheets 1

Status
Not open for further replies.

Kayrow

Instructor
Mar 25, 2002
2
AU
I'd like to cycle through about 1000 rows in a sheet and copy all rows that have data into another sheet. OR simply delete all the completely blank rows. Has any one got some code to do this?
 
For i = 1000 to 1 step -1


if cells(i,1).value = "" then

cells(i,1).select
selection.entirerow.delete
end if

Next i

Tweak this code to meet your requirements.

Ram P
 
Or just do a sort that palces the blanks at the end of your data.

A.C.
 
Thanks lambuhere1. Works like a dream. I've chucked some code in to find the last row rather than going to a thousand, so it looks like:

Global IntRowStart As Integer
Sub Delete()
range("A1").Select
selection.End(xlDown).Select
ActiveCell.Offset(1, 0).range("A1").Select
IntRowStart = selection.Row
For i = IntRowStart To 1 Step -1
If Cells(i, 1).Value = "" Then
Cells(i, 1).Select
selection.EntireRow.Delete
End If
Next i
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top