title: excel 2010 vba loop through declared variabels syntax results in Compile error Variable not defined
body: <p>I declared 5 integers </p>
  
  <pre><code>    Public Hol_1 as integer
      Public Hol_2 as integer
      Public Hol_3 as integer
      Public Hol_4 as integer
      Public Hol_5 as integer
  </code></pre>
  
  <p>Imagine I have 3 clients, then I will use Hol_1 to Hol_3. This also means: iClients = 3
  First thing I need to do is look in my sheets("Holidays") to determine how much holidays each of my 3 clients have.</p>
  
  <pre><code>    Sub CountHolidays()
  
      Dim i as integer
      Dim iclients as integer
      iclients = 3
      For i=1 to iclients 
          Hol_i = WorksheetFunction.CountA(ActiveWorkbook.Sheets("Holidays").Range(Cells(2, 3 + i), Cells(50, 3 + i))) 
         'The worksheetfunction calculates the amount of Holiday-dates I have for each of my three clients
      Next i
      End sub
  </code></pre>
  
  <p>I get a compile error saying Variable is not defined:   Hol_i is not defined. I tried "Hol_" &amp; i and others but was not able to correct this. Does anybody has an idea? THX</p>