+ Reply to Thread
Results 1 to 2 of 2

Can I use a defined integer in an OFFSET method?

  1. #1
    BrookStevenson
    Guest

    Can I use a defined integer in an OFFSET method?

    I have a looped macro for opening files and copy/paste some info from them.
    In order to keep this info from overwriting I want to use an offset. Here is
    a what I need:

    Dim y As Integer
    y = (D152 * 2)
    ActiveCell.Offset(0, y).Select

    I'm new to VBA so I not sure if this is possible, but this was the best
    solution I could come up with... but still doesn't selct an offested cell
    (D152=COUNT(O151:DL151))

  2. #2
    Myrna Larson
    Guest

    Re: Can I use a defined integer in an OFFSET method?

    VBA doesn't know what you mean by D152. It assumes you have an undeclared
    variable by that name.

    You need to tell it you are talking about a worksheet cell, i.e.

    Dim y As Integer
    y = Range("D152").Value * 2
    ActiveCell.Offset(0, y).Select

    BUT.... you are offsetting by Y columns, not by Y rows. And there are only 256
    columns on a worksheet. If you mean to move *down* Y rows, it should be

    ActiveCell.Offset(y, 0).Select

    On Tue, 22 Mar 2005 18:23:03 -0800, "BrookStevenson"
    <[email protected]> wrote:

    >I have a looped macro for opening files and copy/paste some info from them.
    >In order to keep this info from overwriting I want to use an offset. Here is
    >a what I need:
    >
    >Dim y As Integer
    >y = (D152 * 2)
    >ActiveCell.Offset(0, y).Select
    >
    >I'm new to VBA so I not sure if this is possible, but this was the best
    >solution I could come up with... but still doesn't selct an offested cell
    >(D152=COUNT(O151:DL151))



+ 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