+ Reply to Thread
Results 1 to 16 of 16

Compile Error with Application.InputBox

  1. #1
    Registered User
    Join Date
    07-27-2020
    Location
    Frankfort, IL
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    8

    Compile Error with Application.InputBox

    Hello, I am working on a project where I need to have the user select a range and pass that to my macro. It seems like the best way to do this is through the application.inputbox method, however it seems like excel does not even know that this method exits. Every time I try to use it, I get a compile error, "Method or data member not found".

    Below is a sample code that generates the error for me:

    Please Login or Register  to view this content.
    I have not been able to find any similar issues through searching online. I'm guessing that I may need to add in a reference library, but haven't found any information on which one would be needed.

    For reference, the VBA inputbox works fine, however that one does not have the "Type" argument to allow a range to be selected. If anyone has any thoughts on this, I would greatly appreciate it!

    Thank you for your help.

  2. #2
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,114

    Re: Compile Error with Application.InputBox

    Hello Rj,

    Try switching the title and prompt around. The range InputBox requires an "order of things".
    The title is optional, the prompt is required but needs to go first.

    Cheerio,
    vcoolio.

  3. #3
    Registered User
    Join Date
    07-27-2020
    Location
    Frankfort, IL
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    8

    Re: Compile Error with Application.InputBox

    Thanks for the quick response vcoolio. I'm not sure when I switched that out of order, but in any event, I just switched it back as you recommended and I still get the same compile error. Though you did probably save me a headache down the line once I get this compile error fixed!

  4. #4
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,114

    Re: Compile Error with Application.InputBox

    Hello Rj,

    I can't recreate the error with a little test I did. Are any lines high-lighted in your code when the error arises?

    I need to have the user select a range and pass that to my macro.
    How are you doing this?

    Cheerio,
    vcoolio.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Compile Error with Application.InputBox

    rjprince83

    If you try the code in a new, blank workbook in a new instance of Excel do you still get the compile error?
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    07-27-2020
    Location
    Frankfort, IL
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    8

    Re: Compile Error with Application.InputBox

    Quote Originally Posted by vcoolio View Post
    Hello Rj,

    I can't recreate the error with a little test I did. Are any lines high-lighted in your code when the error arises?
    Yes, the .InputBox always gets highlighted when I get the error.


    How are you doing this?
    The intent was to do it through the input box. I don't know of a better way outside of making sure the user selects the range prior to starting the macro, but that seems like it would cause issues if they forgot to select it properly.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Compile Error with Application.InputBox

    When you goto Tools>References... in the VBA IDE what's checked, also is anything marked as MISSING?

  8. #8
    Registered User
    Join Date
    07-27-2020
    Location
    Frankfort, IL
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    8

    Re: Compile Error with Application.InputBox

    Quote Originally Posted by Norie View Post

    If you try the code in a new, blank workbook in a new instance of Excel do you still get the compile error?
    Actually no, when I just tested this it worked fine in a new workbook. That's encouraging... do you happen to have any ideas why it wouldn't work in workbook I need it in?

    Thank you for your help!

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Compile Error with Application.InputBox

    Have you named anything in the workbook where you are getting the error 'InputBox' or something similar?

    Can you attach the problem workbook?

  10. #10
    Registered User
    Join Date
    07-27-2020
    Location
    Frankfort, IL
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    8

    Re: Compile Error with Application.InputBox

    Quote Originally Posted by Norie View Post
    When you goto Tools>References... in the VBA IDE what's checked, also is anything marked as MISSING?
    The checked ones are Visual Basic for Applications, Microsoft Excel 16.0 Object Library, OLE Automation, Microsoft Office 16.0 Object Library, Microsoft Forms 2.0 Object Library.

    I'm not sure what you mean by anything marked as missing. There are dozens that are unchecked, I don't see anything that specifically says "MISSING" though.

  11. #11
    Registered User
    Join Date
    07-27-2020
    Location
    Frankfort, IL
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    8

    Re: Compile Error with Application.InputBox

    Quote Originally Posted by Norie View Post
    Have you named anything in the workbook where you are getting the error 'InputBox' or something similar?

    Can you attach the problem workbook?
    I don't think I can attach the full workbook because there is potentially some proprietary as well as private client information in there. I just tried to strip out all the workbook data to be able to send it that over, and now it is working fine. So there is definitely something in the workbook itself that is causing it. I do have a bunch of named ranges, could that have something to do with it?

    Thanks again for your help.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Compile Error with Application.InputBox

    Have you named any of the named ranges, or anything else e.g. sub, variable etc, 'InputBox'?

  13. #13
    Registered User
    Join Date
    07-27-2020
    Location
    Frankfort, IL
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    8

    Re: Compile Error with Application.InputBox

    Ohhhhh, I'm so dense. I named one of the worksheets "Application". I changed that and it fixed it. Thank you SO MUCH for your help, this was driving me absolutely crazy.

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Compile Error with Application.InputBox

    Sounds like that's the problem.

    Note, the problem would only occur if you set the codename of the sheet to 'Application', you could still use that for the tab name.

  15. #15
    Registered User
    Join Date
    07-27-2020
    Location
    Frankfort, IL
    MS-Off Ver
    Excel for Microsoft 365 MSO
    Posts
    8

    Re: Compile Error with Application.InputBox

    Yes, you're correct. I had it in there as "Application" in the VBA codename, the display name was different. Thanks again, I really appreciate it!

  16. #16
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,114

    Re: Compile Error with Application.InputBox

    Hello Rj,

    Looks like Norie took you down the right path. Good to see it is all sorted.

    Cheerio,
    vcoolio.

+ 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] Inputbox compile error
    By rtcwlomax in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2017, 08:00 AM
  2. [SOLVED] Error if user cancels out of Application.InputBox
    By KT999 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-03-2014, 03:31 PM
  3. [SOLVED] Error when hitting cancel on Application.InputBox
    By wigtown_deano in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2013, 05:26 AM
  4. Using Application.Inputbox.........getting type mismatch error
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-21-2011, 07:33 AM
  5. Error Prevention Application.InputBox
    By AccountantCost in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-07-2009, 06:43 PM
  6. Compile error: Invalid qualifier with inputbox
    By grime in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2006, 06:01 PM
  7. Compile error in my Application
    By elloss in forum Excel General
    Replies: 1
    Last Post: 02-20-2006, 10:30 AM

Tags for this Thread

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