+ Reply to Thread
Results 1 to 5 of 5

Range syntax

  1. #1
    Dr.Schwartz
    Guest

    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. #2
    K Dales
    Guest

    RE: 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. #3
    Norman Jones
    Guest

    Re: Range syntax

    Hi Dr. Schwartz,

    Try:

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


    ---
    Regards,
    Norman



    "Dr.Schwartz" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #4
    Dr.Schwartz
    Guest

    RE: 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


  5. #5
    Dr.Schwartz
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1