+ Reply to Thread
Results 1 to 8 of 8

MsgBox to start macro for other spreadsheet (OK) or cancel

  1. #1
    Registered User
    Join Date
    11-22-2012
    Location
    Maastricht, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    5

    MsgBox to start macro for other spreadsheet (OK) or cancel

    Hi,

    I am working on a VBA to switch to another active worksheet (other file) and start or cancel a macro.

    With a MsgBox the user can validate if he would like to run the macro on the spreadsheet (name is showed) or not. The cancel part is working, the OK part as well, however, the macro runs in the spreadsheet with the command buttons and not in the intended spreadsheet.

    Please Login or Register  to view this content.
    So I would like to run the macro's from one spreadsheet with command buttons on different spreadsheets.

    Looking forward to receive tips.

    Kind regards,

    Nicooo

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: MsgBox to start macro for other spreadsheet (OK) or cancel

    Hope x variabe used in
    Please Login or Register  to view this content.
    has value of this other workbook name
    In the code you've shown this is the most probable prroblem cause. The other possibel problem source is: where the code is placed - is it in standard module or in worksheet code?
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    11-22-2012
    Location
    Maastricht, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: MsgBox to start macro for other spreadsheet (OK) or cancel

    Hi Kaper,

    Thank you for your quick response.

    The workbook names are different each time because they show the date and time of when the export is created/downloaded. This macro is listed in 'Module 1'.

    Please find the file which I would like to use as dashboard with command buttons attached (EDIT: I cannot attach the file to the post).

    Kind regards,

    Nicooo
    Last edited by Nicooo; 09-21-2017 at 04:43 AM. Reason: Attachment

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: MsgBox to start macro for other spreadsheet (OK) or cancel

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  5. #5
    Registered User
    Join Date
    11-22-2012
    Location
    Maastricht, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: MsgBox to start macro for other spreadsheet (OK) or cancel

    Hi Kaper,

    Thank you, attached now.

    Hope you can help me out.

    Kinds regards,

    Nicooo
    Attached Files Attached Files

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: MsgBox to start macro for other spreadsheet (OK) or cancel

    In Kitting procedure (you shown, and the one in attached workbook) all te code for displaying the other workbook name, show msgbox, etc. is disabled, because the
    '
    at the beginning of the line converts given line to a comment (not excecuted part).

    As I already suspected ;-), after removing apostroph signs, variable x (a file to open) is not assigned (and not defined).

    Try something like:
    Please Login or Register  to view this content.
    BTW. I'm a bit worried by "creëren" in msgbox - do you plan to create new file or to use (second) one which is open?

  7. #7
    Registered User
    Join Date
    11-22-2012
    Location
    Maastricht, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: MsgBox to start macro for other spreadsheet (OK) or cancel

    Hi Kaper,

    That's working. Thanks a lot!

    It has to use the second file open.

    Kind regards,

    Nicooo

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: MsgBox to start macro for other spreadsheet (OK) or cancel

    Hi,

    Glad to hear that

    It would be also lovely if you could marke thread SOLVED (use "thread tools" above your first post, and "add me some reputation" by clicking a small star icon in lowerleft corner of my post(s). (and confirming in pop-up that "you agree").
    As opposite to many other sites, you can grant reputation to several posts of one/many users and not only in threads started by you.

    Best Regards,

+ 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] Pop out msgbox whenever expiry date is today and cancel if action done.
    By jp16 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-04-2017, 04:50 AM
  2. [SOLVED] "Cancel" in a MsgBox Yes/No/Cancel is NOT cancelling
    By ongcaps in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2016, 10:36 AM
  3. If msgBox "File is locked for editing appears" then click cancel and end macro
    By biancam3392 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2015, 03:25 AM
  4. [SOLVED] Correct msgbox when user decide to hit Cancel in Save as dialog box
    By Chrispelletier in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2014, 07:17 AM
  5. Make the macro unable to start unless dates in the spreadsheet are correct
    By Hjahren in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-30-2010, 10:49 AM
  6. Cancel button to cancel the whole macro
    By excelnut1954 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-17-2006, 04:30 PM
  7. Cancel Macro is user selects 'cancel' at save menu
    By Mark in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2005, 01:06 PM

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