+ Reply to Thread
Results 1 to 7 of 7

InputBox to accept more than 1 data type

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2013
    Posts
    3,184

    InputBox to accept more than 1 data type

    I'm wondering if there's a way to have an inputbox that can either accept a range or a string. I'm making a "Paste to visible Cells" macro, and would like to make interface both simple and useful. If I'm pasting it should be from either a range, or a value that I input, so I'm hoping there's a way to have the same inputbox accept either.

    I know I could do this with a form, but would rather not go that route if I can help it.
    I know I'm not stupid, but I suspect I'm a lot stupider than I think I am

  2. #2
    Valued Forum Contributor
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365
    Posts
    1,093

    Re: InputBox to accept more than 1 data type

    https://docs.microsoft.com/en-us/off...ation.inputbox

    just add the two together
    range = 8
    value = either 1 or 2

    1 = A number
    2 = Text (a string)

    do you need the actual syntax?

    Set rng = Application.InputBox("Range:", Type:=10)

  3. #3
    Forum Expert
    Join Date
    09-10-2017
    Location
    Chippenham
    MS-Off Ver
    2013
    Posts
    4,188

    Re: InputBox to accept more than 1 data type

    If you mean you can either select a range on the sheet, or type in something like A1:F15, you can simply use
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2013
    Posts
    3,184

    Re: InputBox to accept more than 1 data type

    Fluff13, no, I mean either select a range on the sheet or type in something like "This is the value I want to paste into all of my cells".

    dmgov, an example would be excellent. On the link you provided I didn't see an example of an "either type" inputbox.

  5. #5
    Valued Forum Contributor
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365
    Posts
    1,093

    Re: InputBox to accept more than 1 data type

    Please Login or Register  to view this content.
    the type (where it is set to ten) says that the inputbox will accept a range or a string.

    is that what you are looking for?

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2013
    Posts
    3,184

    Re: InputBox to accept more than 1 data type

    Holy Moley, you literally meant "just add the two together". I was thinking something like
    Please Login or Register  to view this content.
    . Let me play with this, but it looks like it'll work. Let you know in a few minutes.

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2013
    Posts
    3,184

    Re: InputBox to accept more than 1 data type

    Darn, I can't tell yet if it's working, because I've got to refigure my logic.See my code below. I started out with copying a filtered range and pasting ti to a filtered range. Then I thought "What if I want to paste just a certain value to a filtered range" (I know, I can just copy the value and do a straight paste, but wanted the option in the macro). The problem now is with the Rng1 variable; somehow I need to test it to see if it's a range or a string. Any ideas?
    Please Login or Register  to view this content.

+ 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