+ Reply to Thread
Results 1 to 4 of 4

Offset with variable?

Hybrid View

  1. #1
    John
    Guest

    Offset with variable?

    I get an error on this simple line of code...

    st1 = st1.Offset(1, 0)

    st1 is a range... is there anyother way to make st1 step one cell down?

  2. #2
    Norman Jones
    Guest

    Re: Offset with variable?

    Hi John,

    Try:

    Set st1 = st1.Offset(1,0)


    ---
    Regards,
    Norman



    "John" <John@discussions.microsoft.com> wrote in message
    news:EDFB9F8D-FFFF-4D74-94F8-E76AEB0ED6E1@microsoft.com...
    >I get an error on this simple line of code...
    >
    > st1 = st1.Offset(1, 0)
    >
    > st1 is a range... is there anyother way to make st1 step one cell down?




  3. #3
    John
    Guest

    Re: Offset with variable?

    thanks

    "Norman Jones" wrote:

    > Hi John,
    >
    > Try:
    >
    > Set st1 = st1.Offset(1,0)
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "John" <John@discussions.microsoft.com> wrote in message
    > news:EDFB9F8D-FFFF-4D74-94F8-E76AEB0ED6E1@microsoft.com...
    > >I get an error on this simple line of code...
    > >
    > > st1 = st1.Offset(1, 0)
    > >
    > > st1 is a range... is there anyother way to make st1 step one cell down?

    >
    >
    >


  4. #4
    Jake Marx
    Guest

    Re: Offset with variable?

    Hi John,

    John wrote:
    > I get an error on this simple line of code...
    >
    > st1 = st1.Offset(1, 0)
    >
    > st1 is a range... is there anyother way to make st1 step one cell
    > down?


    Since st1 is a Range object, you need to use the Set command if you want to
    change its reference. Otherwise, VBA is going to assign the Value of the
    cell below st1 to the cell referred to by st1. You shouldn't get an error,
    though - that line of code executes for me, it just yields unexpected
    results.

    Dim st1 As Range

    Set st1 = Range("A1")
    Set st1 = st1.Offset(1,0) '/ now st1 refers to B1

    --
    Regards,

    Jake Marx
    www.longhead.com


    [please keep replies in the newsgroup - email address unmonitored]



+ 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