+ Reply to Thread
Results 1 to 7 of 7

Activate VB Macro when opening excel file

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Activate VB Macro when opening excel file

    Hi:

    I have VB Code (macro) in sheet2 of excel file.
    I need to code which will ask if i want to run the macro. ( Y/N)

    Please help me with this simple solution.

    Thanks

    RM

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Activate VB Macro when opening excel file

    Hi,

    Immediately before your macro code

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Activate VB Macro when opening excel file

    Hi Richard:

    Thank you for your qucik help.
    I meant was:

    when i go to sheet2, it should ask if i want to run macro?

    Sorry for misunderstanding.

    RM

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Activate VB Macro when opening excel file

    In that case put the code I gave you in the Sheet2 Activate event and then follow it with the name of your macro.

    Regards

  5. #5
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Activate VB Macro when opening excel file

    Hi Richard:

    Sorry but i did not understand "Acticate Event"

    Please refer to attached excel sheet...the macro is in CLOCKIN-OUT.

    Thanks

    RM
    Attached Files Attached Files

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Activate VB Macro when opening excel file

    Hi,

    I meant you to put the macro in the Sheet2 Activate event. i.e. the event that is triggered whenever you move to sheet 2.

    You originally mentioned sheet 2 but there is no sheet named 'Sheet2' either as a tab name or as a VBA code name. I'm assuming therefore that you mean the second tab name called 'Calc'

    I've put the macro in the SheetChange event of the Calc sheet therefore.

    Regards
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Activate VB Macro when opening excel file

    Hi Richard:

    Thanks, this will work for me..
    Hey, what code would i need to add so that the Paste part in Sub Ert() would be sorted Ascending.

    Appreciate your help.

    RM

+ 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