Results 1 to 4 of 4

Thread: VBA to disable a sub within a module from running
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Jan 2015
    Posts
    239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA to disable a sub within a module from running

    Hi

    I would like to use a pop prompt to disable a particular sub within a module from running?

    The prompt would appear on opening of the workbook. If the user clicks "No" this would disable the sub from running.

    Is this possible to achieve?

    Many thanks

  2. #2
    Board Regular steve the fish's Avatar
    Join Date
    Oct 2009
    Location
    Midlands, UK
    Posts
    7,651
    Post Thanks / Like
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)

    Default Re: VBA to disable a sub within a module from running

    Something like this within the ThisWorkbook module:

    Code:
    Private Sub Workbook_Open()
    
    If MsgBox("Do you want to run macro?", vbYesNo) = vbYes Then
        Call macro1
    End If
    
    End Sub

  3. #3
    Board Regular
    Join Date
    Jan 2015
    Posts
    239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA to disable a sub within a module from running

    Thanks Steve,

    Apologies I don't think I was clear originally

    There is one master macro which runs several other macros (using Call..) and the user does this by clicking a button. It is one the other sub macros that I need disabling if possible on opening.

    thanks again, and hope I'm being clearer

  4. #4
    Board Regular steve the fish's Avatar
    Join Date
    Oct 2009
    Location
    Midlands, UK
    Posts
    7,651
    Post Thanks / Like
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)

    Default Re: VBA to disable a sub within a module from running

    What do you need running if i open the workbook and click no?

    What do you need running if i open the workbook and click yes?

    If it isnt needed in a open event its best to do that via the button click.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •