+ Reply to Thread
Results 1 to 6 of 6

Use input box result to select a cell

  1. #1
    Registered User
    Join Date
    01-21-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Use input box result to select a cell

    Hi again. I am trying to use the result of an input box to determine which cell is selected. As a wider picture, I am copying data from a workbook and pasting into another - but the user needs to select which cell the data is pasted into. So far I have this:

    Please Login or Register  to view this content.
    The input box works but I can't get it to select the cell that I input.

    Could anyone help please?

    Thank you.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: Use input box result to select a cell

    InputBox returns a string and Range() can take a string as an argument. I got this to work by changing the type of variable r from Range to String.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Use input box result to select a cell

    Another thought; If you look at the paramiters of an InputBox.

    InputBox(Prompt, Title, Default, Left, Top, HelpFile, HelpContextId, Type)

    Look at Type 8. It is a cell reference.

  4. #4
    Registered User
    Join Date
    01-21-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Use input box result to select a cell

    Quote Originally Posted by 6StringJazzer View Post
    InputBox returns a string and Range() can take a string as an argument. I got this to work by changing the type of variable r from Range to String.
    Brilliant, that worked. Thank you!

    Thank you also for the tip stnkynts.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: Use input box result to select a cell

    Quote Originally Posted by stnkynts View Post
    Another thought; If you look at the paramiters of an InputBox.

    InputBox(Prompt, Title, Default, Left, Top, HelpFile, HelpContextId, Type)

    Look at Type 8. It is a cell reference.
    This is actually a better solution from a user interface standpoint because it allows the user to select the cells instead of typing in a range, which could have an error. However, note that the version of InputBox with a Type argument is a method of Application, not the built-in function.

    Your code could be written like this:
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Use input box result to select a cell

    Quote Originally Posted by 6StringJazzer View Post
    However, note that the version of InputBox with a Type argument is a method of Application, not the built-in function.
    Oops. Forgot to mention that. Thanks for the catch.

+ 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