+ 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
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,946

    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 dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    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 Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,029

    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
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,946

    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 dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    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
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,946

    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
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,946

    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)

Similar Threads

  1. [SOLVED] Write results of inputbox vertical, dont accept text but numbers only
    By JohnGreen2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-22-2019, 08:32 AM
  2. InputBox Cancel causes type mismatch
    By JElliott95 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-29-2015, 11:55 PM
  3. Application.InputBox Type:Array
    By pulsar777 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-12-2015, 07:02 AM
  4. [SOLVED] Modify macro to repeat once, accept a different file type and paste into different columns
    By vegetable in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-07-2013, 12:46 PM
  5. Data Validation to accept only Date Type
    By pblnrao in forum Excel General
    Replies: 1
    Last Post: 06-13-2011, 09:00 AM
  6. InputBox to Accept Negative Value
    By zimbo109 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-26-2010, 11:26 AM
  7. Type Mismatch error on InputBox
    By h_aesa1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2009, 09:21 AM

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