vba for excel global variable declaration RRS feed

  • Question

  • ho bisognno di accedere allO stesso  oggetto da tutti i fogli  e i moduli di una cartella dilavoro excelho creato l'oggetto come public in un modulo,ma qwquando mi riferisco alle proprietà dell'oggettonei singoli foglispesso mi da errori come se  l'oggetto non fosseè inizializzato

    I Need to use an object Among all worksheets of an excel workbook Where To declare that object and How

    Thursday, January 18, 2018 6:13 PM

All replies

  • Hello pieropingi,

    You could declare the object as public object in a standard module. Once you initialize the object, you could call it from any worksheets module or standard module.

    For instance,

    In Module1

    Public num As Integer
    Public Sub initNum()
    num = 10
    End Sub

    In Sheet1

    Sub TEST()
    'you could comment out initNum if you have ever called it
    Debug.Print num
    End Sub

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, January 22, 2018 1:41 AM