+ Reply to Thread
Results 1 to 11 of 11

InputBox Error.

  1. #1
    Registered User
    Join Date
    06-13-2008
    Posts
    21

    InputBox Error.

    Hi,

    I am using an inputbox to get a range a data from the user.

    Please Login or Register  to view this content.
    This works ok if the user selects a range, however if i select the cancel button i get a Run-time error 424, object required.

    jonnyuk3

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning jonnyuk3

    There isn't a dedicated method to catch cancel from the Application.Inputbox object. Just use Excel's generic error trapping method immediately before calling the input box, and reset it straight after, thus :
    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    06-13-2008
    Posts
    21
    Hi Dominic,

    I've tried what you suggested and i still get the same error.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi jonnyuk3

    This code runs fine on its own. The error must be that the empty variable is causing a problem further on. Use something like this ...

    Please Login or Register  to view this content.
    I can't be any more precise than that with only one line of code to look at.

    HTH

    DominicB

  5. #5
    Registered User
    Join Date
    06-13-2008
    Posts
    21
    DominicB,

    Thanks for your help, but i still cant get this to work.

    Here is the full code for the macro.

    Please Login or Register  to view this content.
    The code stops at the Set rngToChart = Application.Inputbox.......... line

    I appreciate your help.

    jonnyuk3

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi jonnyuk3

    I'm not sure why you're having this problem - I've worked one of my previous answers in your code and it seems to work OK for me. I can't fully test it as you seem to be making use of a custom function (IsChartSheetPresent) but see if it works for you :
    Please Login or Register  to view this content.
    If you're still getting an error you may have to post a cut down version of your file.

    HTH

    DominicB

  7. #7
    Registered User
    Join Date
    06-13-2008
    Posts
    21
    DominicB,

    I'm still getting the same error, so I've attached a copy of the file.

    I also now get the aborted message after creating a chart.

    Thanks for this.

    jonnyuk3
    Attached Files Attached Files

  8. #8
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi jonnyuk3

    Quote Originally Posted by jonnyuk3
    I also now get the aborted message after creating a chart.
    Aaah yes, of course you do. An oversight on my part I'm afraid - I should have added an extra line. The bottom four lines of the macro should have read :
    Please Login or Register  to view this content.
    Quote Originally Posted by jonnyuk3
    I'm still getting the same error, so I've attached a copy of the file.
    I'm afraid with the extra line added the routine works perfectly on my machine running Windows XP and XL2007.
    Select a range and click OK a graph is produced.
    Select Cancel and an abrupt message reads "Aborted" (as per the attached image).

    I'm sorry, but I can't really help any further if I can't reproduce the problem. I'll alert the other moderators and see if any of them can reproduce the error.

    DominicB
    Attached Images Attached Images

  9. #9
    Registered User
    Join Date
    06-13-2008
    Posts
    21
    DominicB,

    Thanks for your help.

    I'm running on Vista, I wouldn't have thought that would be a problem. I'll try again on Monday.

    Thanks again.

    jonnyuk3

  10. #10
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    I'm running xl2007 and Dominics code (with the added lines) worked fine, it created the chart no problem once i entered the range in the inputbox correctly (i used A9:F20).
    Not all forums are the same - seek and you shall find

  11. #11
    Registered User
    Join Date
    06-13-2008
    Posts
    21
    Simon,

    Creating the chart is not the problem. As stated in the first post, the error occurs when the user presses the cancel button on the inputbox.

    DominicB,

    I tried running the macro on an xp machine using xl2007 and it works no problem, the error only occurs on vista.

    thanks for your help, i appreciate it.

    jonnyuk3

+ 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