title: Error shows like "Object variable or With block variable not set "
body: <p>While runing the below code I received an error on this line:</p>
  
  <pre><code>appIE.document.getElementById("__tab_tabFilter").Click
  </code></pre>
  
  <p>The error is:</p>
  
  <blockquote>
    <p><em>Object variable or With block variable not set</em></p>
  </blockquote>
  
  <p>A variable <code>sathish</code> should contain a value like <code>"ABC21A"</code>. Please suggest me how to declare this variable. Also, this code needs to run 1000 times to fetch data.</p>
  
  <pre><code>Sub macro()
      Dim appIE As Object
      Dim objElement As Object
      Dim Y As Long
      Dim obj As Object
      Dim r As Long, c As Long, t As Long
  
      Dim objCollection As Object
      Dim eRow As Long
  
      ' Create InternetExplorer Object
      Set appIE = CreateObject("InternetExplorer.Application")
  
      With appIE
         appIE.Visible = False
         appIE.navigate "website"
  
         Do While appIE.Busy Or appIE.ReadyState &lt;&gt; 4
            DoEvents
         Loop
  
         appIE.Visible = True
         appIE.document.getElementById("Username").Value = ""
         appIE.document.getElementById("Password").Value = ""
         appIE.document.getElementById("btnSubmit").Click
  
         Number = Range("A1", Range("A1").End(xlDown)).Rows.Count
  
         For Y = 1 To Number
             sathish = Cells(Y, 1).Value
             appIE.document.getElementById("__tab_tabFilter").Click
             appIE.document.getElementById("filter_ReferenceCode").Value = sathish
             appIE.document.getElementById("filter_btnSetFilter").Click
  
             'Set IE = Nothing
             Set objCollection = appIE.document.getElementsByTagName("TABLE")
  
             For t = 10 To (objCollection.Length - 1)
                 For r = 0 To (objCollection(t).Rows.Length - 1)
                     eRow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
                     For c = 0 To (objCollection(t).Rows(r).Cells.Length - 1)
                         ThisWorkbook.Worksheets(2).Cells(eRow, c + 1) = objCollection(t).Rows(r).Cells(c).innerText
                     Next c
                 Next r
  
                 If t = objCollection.Length - 1 Then
                     Cells(eRow + 1, 1) = ""
                 End If
             Next t
          Next Y
      End With
      ' Set IE = Nothing
  End Sub
  </code></pre>
  
  <p>Using <code>Option Explicit</code> I get the same "Object variable or With block variable not set" error here: </p>
  
  <pre><code>appIE.document.getElementById("__tab_tabFilter").Click
  </code></pre>
  
  <p>HTML:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;span id="__tab_tabFilter" class="ajax__tab_tab"&gt;Filter&lt;/span&gt;
  
  &lt;input name="filter:ReferenceCode" type="text" maxlength="32" id="filter_ReferenceCode" class="textbox" style="width:136px;"&gt;
  </code></pre>