Variable Row Numbers

G

Glynn Taylor

Hello

Using Excel 2000

Having determined the first row with a blank cell A1 I calculate the first
and last rows which I need to copy to another sheet. see below

When I try to select these rows with Rows("first_row:last_row").Select
the macro fails.

Row = 3
While Cells(Row, 1) <> ""
Row = Row + 1
Wend

last_row = Row - 1
first_row = last_row - 11

Rows("first_row:last_row").Select

Any ideas?

Thank you
 
D

Dave Peterson

Try:
Rows(first_row & ":" & last_row).Select

Glynn said:
Hello

Using Excel 2000

Having determined the first row with a blank cell A1 I calculate the first
and last rows which I need to copy to another sheet. see below

When I try to select these rows with Rows("first_row:last_row").Select
the macro fails.

Row = 3
While Cells(Row, 1) <> ""
Row = Row + 1
Wend

last_row = Row - 1
first_row = last_row - 11

Rows("first_row:last_row").Select

Any ideas?

Thank you
 
R

Rick Rothstein \(MVP - VB\)

Anything between quote marks is considered text, even if those characters
spell out the name of a variable. The key is to concatenate the variable
names to the other fixed text...

Rows(first_row & ":" & last_row).Select

Rick
 
D

Don Guillett

A suggestion?

Sub copyrows()
Rows("3:" & Cells(Rows.Count, "a").End(xlUp).Row).Copy
End Sub
 
G

Glynn Taylor

Thanks Rick

Rick Rothstein (MVP - VB) said:
Anything between quote marks is considered text, even if those characters
spell out the name of a variable. The key is to concatenate the variable
names to the other fixed text...

Rows(first_row & ":" & last_row).Select

Rick
 
G

Glynn Taylor

Thanks Don

Don Guillett said:
A suggestion?

Sub copyrows()
Rows("3:" & Cells(Rows.Count, "a").End(xlUp).Row).Copy
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top