How to select certain rows...

M

Mike

I have two variables (type long): first and last. How do
I select the rows first..last and delete them?

Thanks.
 
R

Ron de Bruin

Try this

Sub test()
Dim first As Long
Dim last As Long
first = 12
last = 15
Rows(first & ":" & last).Delete
End Sub
 
J

John Wilson

Mike,

Dim lRow as long
lRow = 2
Range("A" & lRow).EntireRow.Delete

Can do the same for the first row.
Delete the last one first, and the then the first one (just to be safe).

John
 
R

Ron de Bruin

Hi Dennis

We have more then 32767 rows in Excel so a if you dim as integer
the below example will give you a error because 32767 is the limit for a integer

Dim first As Integer
Dim last As Integer
first = 12
last = 32768
Rows(first & ":" & last).Delete

highlight the word long or integer in the code and press F1
The VBA help will tell you all about it
 
Top