+ Reply to Thread
Results 1 to 4 of 4

VBA Code: Reference cell based on offset of selected cell from Application.InputBox

  1. #1
    Registered User
    Join Date
    09-30-2021
    Location
    Dallas, TX
    MS-Off Ver
    Microsoft Office 365 ProPlus, Excel Version 1908
    Posts
    2

    VBA Code: Reference cell based on offset of selected cell from Application.InputBox

    Evening guys,

    I am trying to figure out the correct syntax to get Excel to record a cell reference based on an specified offset of a cell selected using the Application.InputBox function.

    In example, say I select a cell D10 in a spreadsheet for "VolumeSelect" and it is stored as a Variant/String type as ('Sheet'!$D$10). I want VolumeOffset1 to be the cell reference in the same spreadsheet with a specified offset of that selected cell, say one row down and one column to the right ('Sheet1'!$E$11)

    I provided what I have so far. When running the code, I get Run-time error 424 (Object required)

    Any help would greatly be appreciated!
    Attached Images Attached Images
    Last edited by Cm214; 09-30-2021 at 01:00 AM.

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,234

    Re: VBA Code: Reference cell based on offset of selected cell from Application.InputBox

    In the InputBox window, you can see the address of the selected cell in A1 notation, but the variable receives a formula in R1C1 notation. As you mentioned, the VolumeSelect variable holds a Variant / String type, so it is not an object. You somehow need to turn the text into an object.
    For example like this:
    Please Login or Register  to view this content.
    Artik

  3. #3
    Registered User
    Join Date
    09-30-2021
    Location
    Dallas, TX
    MS-Off Ver
    Microsoft Office 365 ProPlus, Excel Version 1908
    Posts
    2

    Re: VBA Code: Reference cell based on offset of selected cell from Application.InputBox

    That seemed to work in converting it into an object. Now the only issue I have is that the cell address is in absolute reference. When executing, the VolumeOffset1 still returns a value of "".

    Is there a way I can turn VolumeSelect from a absolute reference state to a relative reference state?
    Attached Images Attached Images

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,234

    Re: VBA Code: Reference cell based on offset of selected cell from Application.InputBox

    Probably the macro might look like this:
    Please Login or Register  to view this content.
    Artik

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 06-23-2021, 03:19 AM
  2. want the vba code to pick up the email address from the selected radio cell
    By shantanu97 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-26-2021, 01:19 PM
  3. [SOLVED] Return Cell Address for Active/Selected Cell
    By magicaces84 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2014, 11:56 AM
  4. [SOLVED] I Want to know how I can make this formula into vba code for dynamic cell address
    By dgdgdg in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-06-2013, 12:54 PM
  5. Replies: 1
    Last Post: 03-08-2012, 01:57 PM
  6. Excel 2007 : Formula to grab ip address from within text.
    By jayboogee in forum Excel General
    Replies: 2
    Last Post: 07-26-2009, 06:45 PM
  7. Replies: 2
    Last Post: 05-27-2006, 02:50 PM

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