How to select certain rows...

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

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

Thanks.
 
Try this

Sub test()
Dim first As Long
Dim last As Long
first = 12
last = 15
Rows(first & ":" & last).Delete
End Sub
 
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
 
What is the significance of "Variables (Long type)" in VBA?

Are some examples that reflect that significance possible?

Thanks!
 
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
 
Back
Top