title: How do I import csv data from a web download link to Excel using VBA?
body: <p>I use the same code (below) in many files to import data from a company website using a download link in my VBA code. But one particular URL will not work and gives me Run-time error '5' (Invalid procedure call or argument). I have narrowed it down to the dates in the connection string (Mon%20Jan%2003%202022). Is there any code that I can change to accommodate the dates into the download URL?</p>
  <pre><code>Sub ICE_ByNames_Extract()
  '
  ' ICE_ByNames_Extract Macro
  '
  Application.ScreenUpdating = False
  
  ThisWorkbook.Worksheets(&quot;Output&quot;).Range(&quot;A:Z&quot;).ClearContents
  
  Sheets(&quot;Output&quot;).Select
      
  Dim ConnString As String
  
  ConnString = &quot;TEXT;&quot; &amp; &quot;https://ice-core.pcf-phx.apps.boeing.com/api/ManagerStartup/Csv?fromDate=Mon%20Jan%2003%202022&amp;toDate=Sun%20Mar%2020%202022&amp;page=ByNames&amp;rework=&amp;program=CH-47%20ALL&amp;shop=FLIGHT%20TEST&amp;workcenter=&amp;manager=&amp;endItem=M%3A7603&amp;status=&amp;bemsId=3219547&amp;variantId=null&amp;programId=-1&amp;majorProgram=CH-47&quot;
      With ThisWorkbook.Worksheets(&quot;Output&quot;).QueryTables.Add(Connection:=ConnString, Destination:=ThisWorkbook.Worksheets(&quot;Output&quot;).Cells(1, 1))
          .TextFileStartRow = 1
          .TextFileParseType = xlDelimited
          .TextFileCommaDelimiter = True
          .Refresh
     
      End With
    
  
  End Sub
  </code></pre>