Range syntax

G

Guest

How come this piece of code does not work?

Dim Headers As Range
Set Headers = Range(Cells(ImNavigateRow - 1, 2), Cells(ImNavigateRow - 1,
2).End(xlToRight).Column)

I get an: Method 'Range' of object '_worksheet' failed error.

Can anyone correct this for me?
Thanks
The Doctor
 
G

Guest

Perhaps this is what you are trying to do?
Set Headers = Range(Cells(ImNavigateRow - 1, 2), Cells(ImNavigateRow - 1,
Cells(ImNavigateRow-1,2).End(xlToRight).Column))
 
N

Norman Jones

Hi Dr. Schwartz,

Try:

Set Headers = Range(Cells(ImNavigateRow - 1, 2), _
Cells(ImNavigateRow - 1, 2).End(xlToRight))
 
G

Guest

Yes thank you it works, but I think I'm going to use Norman's solution (is't
shorter)
 

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