title: Defining Variables in Userform to be used in module
body: <p>I have seen similar questions raised both on this forum and others, and I tried all combinations I could think of before posting this. I also referenced a few textbooks and more technical sites concerning userforms and cannot seem to get it right.</p>
  
  <p>I create variables in a user form that I want to then reference in my module. I have tried labeling them as global, defining them on both the userform and module, on just the userform, on just the module, and a few other combinations but have not gotten it correct. </p>
  
  <p>This is what I have as of now and by everything I have read should be correct:</p>
  
  <p>*In declaration section of Userform:</p>
  
  <pre><code> Dim ABC as Workbook
   Dim Primary as Workbook
  </code></pre>
  
  <hr>
  
  <p>*In a command button section of Userform</p>
  
  <pre><code>For j = 0 To (ListBox1.ListCount - 1)
      If ListBox1.List(j) Like "ABC" Then
          Set ABC = Workbooks(ListBox1.List(j))
          ABC.Activate
          Exit For
      End If
  Next
  
  For i = 0 To (ListBox1.ListCount - 1)
      If ListBox1.List(i) Like "Aggregate" Then
          Set Primary = Workbooks(ListBox1.List(i))
          Primary.Activate
          Exit For
      End If
  Next 
  </code></pre>
  
  <p>*This continues for a few more variables, each indexed on a different letter. </p>
  
  <p>In module, I then have something like this:</p>
  
  <pre><code>        Primary.Sheets("Summary").Range("A5:H40").CopyPicture Appearance:=xlScreen, Format:=xlPicture
  </code></pre>
  
  <p>My question, as also stated above, is how do I define these workbooks (Primary, ABC, etc.) so that I can use them in my module, like the example above. </p>
  
  <p>And when using in my module, can I just write</p>
  
  <p>Primary.Sheets(.......)....</p>
  
  <p>Or do I need to do Workbooks("Primary").Sheets(....)....</p>
  
  <p>Maybe I should Dim Primary as String and go about it that way? </p>
  
  <p>Thanks!</p>