Results 1 to 10 of 10

Thread: Assign worksheet to Global variable. Possible? or Worth it?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Dec 2022
    Posts
    4
    Location

    Assign worksheet to Global variable. Possible? or Worth it?

    Hello all,
    I'm tying to figure out how to declare a variable of a worksheet as global so that it can be used from any module.
    My best try (failing) looks like this...
    Option Explicit
     
     Public wsI2 As String
     wsI2 = "Input"
     wsI2 = Worksheets(wsI2)
    
     Public wsI As Worksheet
        wsI = Sheets("Input")
    
     Public wsO As Worksheet
        wsO = Sheets("Output")
    
     Public wsR As Worksheet
        wsR = Sheets("Results")
    
     Public HDT As Worksheet
        wsH = Sheets("HDT")
    
     Public HDT As Worksheet
        HDT = Sheets("HDT")
    
     Public GLL As Worksheet
        GLL = Sheets("GLL")
    
     Public GGA As Worksheet
        GGA = Sheets("GGA")
    
     Public HDT As Worksheet
        wsH = Sheets("HDT")
    
    Sub NavPage1()
        wsI2.Select
    End Sub

    I have no idea how to make this work. I've looked everywhere I can think of.
    Last edited by Aussiebear; 10-03-2024 at 01:00 PM. Reason: Added code tags to supplied code

Posting Permissions

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