title: How to refresh SQL query in an Excel sheet while looping through a drop down list with VBA?
body: <p>I am seaking for advice with the following problem.</p>
  <p>I have an Excel sheet I need to refresh and save as PDF about 200 times. I found a code which will allow to loop through a drop down list while creating a PDF for each value in the list. My data in the rest of the sheet is also dependent from the value selected from the list. The code ist working except for the cells where I have values from an SQL query, as the query won't refresh until the loop is running, or any vba code is running. The query has parameters also dependent from the selction of the drop down list. My query is in the same workbook on a seperate sheet. The drop down is in A5, the content of the list is also a query in a seperate sheet, however this only has to be refreshed once before running the code.
  So what I need is to select Value from the drop down list, refresh every cell incl. query, save as PDF, repeat.</p>
  <p>I tried to use Application.CalculateFull and various wait functions to no effect.</p>
  <p>Is it possible to force the SQL query to refresh itself before the PDF is created?</p>
  <pre><code>
  
       Dim inputRange As Range
       Dim c As Range
       
       Set inputRange = Evaluate(Range(&quot;A5&quot;).Validation.Formula1)
                 
          For Each c In inputRange
          
          Range(&quot;A5&quot;).Value = c.Value
                 
                      
                
             ActiveSheet.ExportAsFixedFormat _
              Type:=xlTypePDF, _
             Filename:=&quot;C:\................&quot; &amp; &quot;_&quot; &amp; c.Value, _
              Quality:=xlQualityStandard, _
              IncludeDocProperties:=True, _
              IgnorePrintAreas:=False, _
              OpenAfterPublish:=False
                 
            
                 
          Next c
  
  
  End Sub```
  </code></pre>