title: Excel VBA: Login to Website, Pull data from table
body: <p>i'm want my excel macro to go on to this website, log on, and copy the entire table and paste it on to the excel spreadsheet.</p>
  
  <p>I'm not too familiar with ExcelVba and i don't know what to do after logging into the website.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>Sub DataPulling()
  
  Dim ieApp As InternetExplorer
  Dim ieDoc As Object
  Dim URL As String
  Dim ReportURL As String
  Dim CurrentSheet As Worksheet
  Dim HTML_Element As IHTMLElement
  Dim HTMLDoc As HTMLDocument
  
  'set CurrentSheet as Active Worksheet
  Set CurrentSheet = ActiveSheet
  
  'On the Error, go Err_Clear
  On Error GoTo Err_Clear
  
  'Create a new instance of IE
  Set ieApp = New InternetExplorer
  
  'Declare Web Addresses
  URL = "http://www.login-page.com"
  ReportURL = "http://www.the-table-page.com"
  
  ieApp.Visible = True
  ieApp.Silent = True
  
  'Go to the main website
  ieApp.navigate URL
  
  Do
      Loop Until ieApp.readyState = READYSTATE_COMPLETE
      Set HTMLDoc = ieApp.document
      HTMLDoc.all.UserId.Value = "userid"
      HTMLDoc.all.password.Value = "password"
  
      For Each HTML_Element In HTMLDoc.getElementsByTagName("input")
          If HTML_Element.Type = "submit" Then HTML_Element.Click: Exit For
      Next
  
  ieApp.navigate ReportURL
  
  Do While ieApp.Busy
      DoEvents
  Loop
  
  'I dont know what to put here..!!??
  
  ieApp.Quit
  
  Set ieApp = Nothing
  Set ieDoc = Nothing
  </code></pre>
  
  <p>and the source page of the website looks something like this below..</p>
  
  <pre><code>&lt;div id="divDt" class="dt"&gt;
  &lt;table id="tblActiveProjects" class="display dt" cellspacing="0"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;ContentA1&lt;/th&gt;
              &lt;th&gt;ContentA2&lt;/th&gt;
              &lt;th&gt;ContentA3&lt;/th&gt;
              &lt;th&gt;ContentA4&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;th&gt;ContentB1&lt;/th&gt;
              &lt;th&gt;ContentB2&lt;/th&gt;
              &lt;th&gt;ContentB3&lt;/th&gt;
              &lt;th&gt;ContentB4&lt;/th&gt;
          &lt;/tr&gt;
  </code></pre>