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. #5
    VBAX Newbie
    Joined
    Dec 2022
    Posts
    4
    Location
    So, I have found this works.. Oddly enough, part of the answer was derived from a completely different question.

    What I would like to know is how I can use these as global variables across all modules.



    Option Explicit
    
    Sub SelectPages()
        Dim WB1 As Workbook
        Dim SH1 As Worksheet
        Dim SH2 As Worksheet
        Set WB1 = ThisWorkbook
        Set SH1 = WB1.Worksheets("Sheet1")
        Set SH2 = WB1.Worksheets("Sheet2")
        SH1.Select
        SH2.Select
    End Sub
    Last edited by Aussiebear; 10-03-2024 at 12:58 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
  •