title: My VBA code is not using my Google Distance Matrix API key
body: <p><strong>EDITED FOR CLARIFICATION</strong></p>
  
  <p>I've copied and tweaked some code to connect to the Google Distance Matrix API and I'm having issues going over the free limit.</p>
  
  <p>I have an account and my key has 100K per day enabled, so I'm not sure exactly what the issue is.  This will work for single pulls up to the free limit of 2500 but then return error messages that tell me I've hit the limit.</p>
  
  <pre><code>Public Function GetDistance(start As String, dest As String)
      Dim firstVal As String, secondVal As String, lastVal As String
      firstVal = "http://maps.googleapis.com/maps/api/distancematrix/json?
      origins="
      secondVal = "&amp;destinations="
      lastVal = "&amp;mode=car&amp;language=en&amp;ClientID=[INSERTKEYHERE]"
      Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
      Url = firstVal &amp; Replace(start, " ", "+") &amp; secondVal &amp; Replace(dest, " ", "+") &amp; lastVal
      objHTTP.Open "GET", Url, False
      objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
      objHTTP.send ("")
      If InStr(objHTTP.responseText, """distance"" : {") = 0 Then GoTo ErrorHandl
      Set regex = CreateObject("VBScript.RegExp"): regex.Pattern = """value"".*?([0-9]+)": regex.Global = False
      Set matches = regex.Execute(objHTTP.responseText)
      tmpVal = Replace(matches(0).SubMatches(0), ".", Application.International(xlListSeparator))
      GetDistance = CDbl(tmpVal)
      Exit Function
  ErrorHandl:
      GetDistance = -1
  End Function
  </code></pre>
  
  <p>I have also used key=[INSERTKEYHERE], but that didn't seem to fix the issue, and even made the function not work.  This question was asked here as well, but never publicly resolved.  <a href="https://stackoverflow.com/questions/38485353/google-distance-matrix-api-key-excel-vba">Google Distance Matrix API Key Excel VBA</a></p>
  
  <p>Thanks!</p>