If Macro is disabled

  • Hi,
    I am pretty sure I have read this on this forum but can not seem to find it.
    I want VBA code that:
    When you enable macros the sheets 2, 3, 4 ect are visible but if you disable macros, you only see sheet 1 and and you can place a message on the sheet saying this will only work with macros enabled.
    Appriciate if someone can point me in the right direction if this is already somewhere on this forum.
    Kindest Regards,

  • Re: If Macro is disabled

    Hi guggu,

    In my little world I would use

    Private Sub Workbook_Open()
        Sheets("Sheet2").Visible = True
        Sheets("Sheet3").Visible = True
    ' etc etc etc
    End Sub

    in 'ThisWorkbook'.

    Something to to consider is to hide the sheets when closing the workbook, because what if the workbook was saved with sheets visible... then you get an error. I guess you could check, if xyz is visible dont do a thing, or, what i'd add is a 'On Error Resume Next' before the ...visible true...?

    I suppose something like this

    Sheets(Array("Sheet2", "Sheet3")).Visible = False 'add/adjust as needed

    could be placed into a 'Private Sub Workbook_Close()'.

    I'm sure there are more genius ways to do that though.


    While this may be "a given", the above assumes that the workbook was saved with the sheets hidden to begin with.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!