delete rows
But if you wanted, you could take advantage of what excel did:
Sub deleterows()
Dim i As Long
For i = 1 To 16
Rows(1).Delete
Next i
End Sub
It's always deleting row 1 and shifting rows up.
You could use:
rows(1 & ":" & 16).delete
or
rows("1:16").delete
or
range("A1").resize(16,1).entirerow.delete
=========
But I expect that you're doing more than just deleting 16 rows. I bet you're
using some criteria to determine if you should delete the row.
You could use:
Dim myCell as range
dim myRng as range
dim delRng as range
with worksheets("Somesheetnamehere")
set myrng = .range("A1", .cells(.rows.count,"A").end(xlup))
end with
for each mycell in myrng.cells
if lcase(left(mycell.value,1)) = lcase("u") then
'keep it
else
if delrng is nothing then
set delrng = mycell
else
set delrng = union(mycell, delrng)
end if
end if
next mycell
if delrng is nothing then
'nothing to delete
else
delrng.entirerow.delete
end if
helene and gabor wrote:
Hello,
My simple program would make me believe that all rows 1 to 16 will be
deleted.
Not so. Only the odd numbered entries in col.A got deleted, entries
2,4,6,....16 remained.
My simple program is this:
------------------------------------------------------------------------------
Sub deleterows()
Dim i As Long
For i = 1 To 16
Rows(i).Delete
Next i
End Sub
--------------------------------------------------------------------------------
Thanks for your help.
Regards,
Gabor Sebo
--
Dave Peterson
|