title: Counting number of headers in an Access Query and Finding the Max
body: <p>I am using VBA and I am exporting some <code>Access</code> queries to Excel. This macro is being built on the <code>Access</code> side. I have an array of queries such as:</p>
  
  <p><code>Qs = Array(q1, q2, q3)</code></p>
  
  <p>I need to <code>count</code> the number of headers in each query and find the <code>max</code>.</p>
  
  <p>Based on a couple searches, I found you can use the <code>WorksheetFunction.Max</code> but I am getting an <code>"Object Required" error</code>.</p>
  
  <p>Here is the code I am trying that is raising an error:</p>
  
  <pre><code> WorksheetFunction.Max(Qs(0).Fields.Count, Qs(1).Fields.Count, Qs(2).Fields.Count) 
  </code></pre>
  
  <p>Is there another way to do this? </p>
  
  <p>P.S. I already added a reference to <code>Microsoft Excel 14.0 Object Library</code></p>