Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Range syntax

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Range syntax

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))

"Dr.Schwartz" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Range syntax

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

"K Dales" wrote:

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))

"Dr.Schwartz" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Range syntax

Hi Dr. Schwartz,

Try:

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


---
Regards,
Norman



"Dr.Schwartz" wrote in message
...
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Range syntax

As always (2 for 2) you deliver, thank you Norman.

"Norman Jones" wrote:

Hi Dr. Schwartz,

Try:

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


---
Regards,
Norman



"Dr.Schwartz" wrote in message
...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with the syntax for using range name in a formula? BRC[_2_] Excel Discussion (Misc queries) 2 January 9th 10 06:16 PM
VB Syntax to select a range xjetjockey Excel Discussion (Misc queries) 4 January 17th 07 03:12 AM
Need help with creating a Range Name syntax Gary''s Student Setting up and Configuration of Excel 0 February 4th 06 06:52 PM
range and cells syntax mango Excel Worksheet Functions 0 February 22nd 05 12:03 AM
Syntax for Range Reference Ken Excel Programming 1 December 8th 04 05:15 PM


All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"