title: Using Global Variables in VBA
body: <p>Just started using VBA within the past week, and am playing around with Sheets vs. Modules and defining variables.  Here is the code I currently have:</p>
  
  <p>Sheet1: </p>
  
  <pre><code>Dim writtenvoe As Boolean
  Dim verbalvoe As Boolean
  Dim voerequired As Boolean
  Dim CA14 As Boolean
  Dim CA15 As Boolean
  Dim W2s As Boolean
  Dim tranapp As Boolean
  </code></pre>
  
  <p>Module1:</p>
  
  <pre><code>Public Sub ImpDocs()
  
  'Is written voe on file?
  If Sheet1.CheckBox6.Value = True Or Sheet1.CheckBox8.Value = True Or Sheet1.CheckBox9.Value = True Or Sheet1.CheckBox10.Value = True Then writtenvoe = True Else writtenvoe = False
  If Sheet1.CheckBox6.Value = True Then Sheet1.[O40] = "hello" Else Sheet1.[O40] = ""
  If writtenvoe = True Then Sheet1.[O39] = "writtenvoe = true" Else Sheet1.[O39] = "writtenvoe=false"
  
  'Is verbal voe on file?
  If Sheet1.CheckBox11.Value = True Then verbalvoe = True
  
  'Is a written VOE required?
  If Sheet1.CheckBox16.Value = True Or Sheet1.CheckBox18.Value = True Or Not IsEmpty(Sheet1.[H33]) Then voerequired = True
  If voerequired = True Then Sheet1.[J35] = "hello" Else Sheet1.[J35] = ""
  
  'Are tax docs CA14 or CA15?
  If Sheet1.CheckBox31.Value = True Or Sheet1.CheckBox7.Value = True Or Sheet1.CheckBox32.Value = True Or Sheet1.[H29].Value &gt; 25 Then CA15 = True Else CA15 = False
  If CA15 = False Then CA14 = True Else CA14 = False
  
  'Are W-2's on file?
  If Sheet1.CheckBox12.Value = True And Sheet1.CheckBox13.Value = True Then W2s = True
  
  'Are 4506-T's on file?
  If Sheet1.CheckBox60.Value = True And Sheet1.CheckBox61.Value = True Then tranapp = True
  
      'Order Wage transcripts if W-2s and 4506-T not on file
      If W2s = False And tranapp = False And CA14 = True Then Sheet4.fullCA14
  
  End Sub
  </code></pre>
  
  <p>Also Module 1 (2nd Subroutine):</p>
  
  <pre><code>Public Sub test()
  
  If writtenvoe = True Then Sheet1.[N37] = "Yes" Else Sheet1.[N37] = "No"
  
  End Sub
  </code></pre>
  
  <p>I noticed that in this current format, Sub ImpDocs works well and the variables are determined correctly, but Sub test always comes back as false.  However, if I put all of the code into module 1, everythis works as expected.  It seems like only Sub test is affected from declaring variables in Sheet1 vs Module1. Is that true? If so, why? </p>
  
  <p>Thank you.</p>