title: VBA 2 Questions concerning variable scope and lifetime
body: <p>I've run accross two issues on what I'm trying to do with VBA concerning a variable's scope and lifetime.</p>
  
  <ol>
  <li><p>I have different subs which use the same variables over and over and over. For example an integer that defines a column as a date column, cDate, or app as Application. Since I have a sizable declarations section I wanted to put this in a seperate module using Global but this did not work. Does it matter how I set the procedure scope here? How can I do this?</p></li>
  <li><p>Similar to Q1, what about intializing variables? Specifically, instead of copying and pasting the same block which finds column headers (e.g. cDate), I put it into its own procedure. I'm running accross many problems trying to get this to work. I would hope this is possible, maybe not. </p></li>
  </ol>
  
  <p>Tell me if you need to see code. Tell me what ou want to see and I throw it up here. (PS- I have gone through VBA Help, MSDN, Goole, etc and there is something I'm not understanding here)</p>
  
  <p>Edit: adding edited code because the real thing is pretty long. All sections are in separate standard modules. I had read Global declarations only work at the workbook level and below and so I also tried declaring and setting <code>app</code>, <code>wb</code>, and <code>wrk</code> as <code>Public</code> in each module (not shown here):
  Here's my declarations:</p>
  
  <pre><code>Option Explicit
  
  Global app As Application
  Global wb As Workbook
  Global wrk As Worksheet
  
  Global cInvoice As Byte
  
  Global iEndCol As Integer
  Global lEndRow As Long
  Global x As Integer
  
  Global sString1 As String
  
  Global rng As Range
  
  Private Sub Not_Really_a_sub()
      'No code. I read that any declaration needed to be in a module 
      ' with a procedure. I tried it with out the dummy sub also
  End Sub
   'green text, read me and notes
  </code></pre>
  
  <p>And the sub that does the calling:</p>
  
  <pre><code>   Dim modulevariables As Integer
  
  Sub Calling_Sub()
  
   'doing things
  
   lEndRow = 1 'blah blah blah
   iEndCol = 1 ' blah blah blah
   app.Run "'" &amp; ThisWorkbook.Name &amp; "'!Header_Finder"
  
    'Code using cInvoice etc.
  
  End Sub
  </code></pre>
  
  <p>And the Header finder:</p>
  
  <pre><code>Private Sub Header_Finder()
    With wb.ActiveSheet
      For x = 1 To iEndCol
          If InStr(UCase(.Cells(x, 1)), UCase("Invoice")) &gt; 0 Then
              cInvoice = x
          ElseIf .Cells(1, x) = "next thing" Then
              cNextThing = x
          End If
      Next
   End With
  End Sub
  </code></pre>
  
  <p>Thanks already.</p>