using the range method

M

mike

i want to select certain columns and rows and use this
selection to create a chart. The selection is in a loop
and the cell locations will vary every time it is run.
Here's my code:

Worksheets(1).Range(Cells(startRow, 16), Cells(endRow,
18)).Select

where "startRow" and "endRow" are integers.

I always get the error that "Method 'Cells' of
object '_Global' failed" Am I using the wrong format for
the Range method?
thanks in advance
 
A

Alan Beban

J.E. McGimpsey said:
or the much more efficient:

With Worksheets(1)
.Range(.Cells(startRow, 16), .Cells(endRow, 18)).Select
End With

One might also consider

Set rng = Worksheets(1).Range("A1")
Range(rng(startRow, 16), rng(endRow, 18)).Select

Alan Beban
 

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