title: vba: how to insert value within html table?
body: <p>I can't find a way to pupulate html table clumn, that has a dynamic id - 
  The id changes everytime I open a new session.</p>
  
  <p>If I manualy populate column(1/10/2019) with "1"(hour) - in the next session the id for column(1/10/2019) becomes constant, and I can use "application.sendkeys ("7")" to change the value to "7"(hours) for example.</p>
  
  <p>How can I populate a column within the html table, that I haven't inserted manualy any values before? What is the propper way to approach this task?</p>
  
  <pre><code>Sub Treport()
  
  'Make the app work faster?
  Application.ScreenUpdating = False
  Application.DisplayAlerts = False
  '--------------------------------
  Dim sht As Worksheet
  Set sht = ThisWorkbook.Sheets("Report_Time") 'my data will be stored here
  '--------------------------------
  Dim LastRow As Long
  LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row 'range definition
  '--------------------------------
  Dim i As Long            'Will be used for a loop that navigate to different url
  For i = 2 To LastRow     'variable range
  Dim IE As Object         'Internet Explorer declaration
  Set IE = CreateObject("InternetExplorer.Application") 'Opens browser
  IE.Visible = True
  
  IE.navigate sht.Range("A" &amp; i).Value 'My url that I want to navigate to
  While IE.readyState &lt;&gt; 4 Or IE.Busy: DoEvents: Wend 'wait until site fully loads
  
  Dim Doc As New HTMLDocument 'Will be used for the main html page
  Set Doc = IE.document
  
  Doc.getElementById("imgLastWeek").Click 'Here I click to navigate within the timesheet to the desired time range
  While IE.readyState &lt;&gt; 4 Or IE.Busy: DoEvents: Wend 'wait untill page loads again
  Doc.getElementById("9da306a8-b813-46ff-b94f-45636f401ba8").Click 'need to click the column before inseting a value
  Application.Wait Now + TimeValue("00:00:2")
  Application.SendKeys ("7") 'here I change value from "1" to "7" in a clumn that I have manualy inserted number before, that is why the id is constant
  
  Next i
  
  Application.DisplayAlerts = True
  Application.ScreenUpdating = True
  
  End Sub
  </code></pre>
  
  <p>I expect to insert hours to columns according the Id of the task + the date of the column. If more of the html is needed to understand the table stracture please advise and I will copy more of the code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table id="tblTimeSheet_tblMain" style="width: 704px; padding-bottom: 0px;" cellspacing="0" s=""&gt;
    &lt;colgroup id="tblTimeSheet_cgMn"&gt;
      &lt;col style="width: 40px;" span="1" u="px" orgwidth="40"&gt;
      &lt;col style="width: 40px;" span="1" u="px" orgwidth="40"&gt;
      &lt;col style="width: 93px;" span="1" u="px" orgwidth="93"&gt;
      &lt;col style="width: 35px;" span="1" u="px" orgwidth="35"&gt;
      &lt;col style="width: 35px;" span="1" u="px" orgwidth="35"&gt;
      &lt;col style="width: 35px;" span="1" u="px" orgwidth="35"&gt;
      &lt;col style="width: 35px;" span="1" u="px" orgwidth="35"&gt;
      &lt;col style="width: 35px;" span="1" u="px" orgwidth="35"&gt;
      &lt;col style="width: 35px;" span="1" u="px" orgwidth="35"&gt;
      &lt;col style="width: 35px;" span="1" u="px" orgwidth="35"&gt;
      &lt;col style="width: 40px;" span="1" u="px" orgwidth="40"&gt;
    &lt;/colgroup&gt;
    &lt;tbody&gt;
      &lt;tr id="0af6368f-79e0-49f8-bbca-15808c556655" style="height: 25px;" s="" pid="1f0305b4-8683-4c61-b85e-3b0b885b6e30"&gt;
        &lt;td align="left" class="r" ct="" s="" dp="2" ah="0" d="0" dt="0" cv="" ae="0" timetype="RemainHrs"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="left" class="r" ct="" s="" dp="2" ah="0" d="0" dt="0" cv="" ae="0" timetype="PerComp"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="center" class="r" ct="" s="" dp="2" ah="0" d="0" dt="4" cv="" ae="0" timetype="ForecastFinish"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="9ab38f91-cd6b-432e-83b2-0033796f7d54" style="background-color: rgb(238, 238, 238);" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/4/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="a7f1f9d2-b9c5-48c8-bc19-7e1d0041d1aa" style="background-color: rgb(238, 238, 238);" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/5/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="edf44c3c-b10e-4cf3-ad91-b91c08662229" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/6/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="b9cd0b45-f864-4003-ac47-5701489c8c3f" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/7/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="00ed8598-26bb-4a10-8481-64ea40149765" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/8/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="Description: &amp;#10;&amp;#13;OT hours: 0.00&amp;#10;&amp;#13;" align="right" class="r" id="806751c3-c2e5-40e2-b269-a0cc99ab18fe" style="color: rgb(128, 128, 144);" ct="1.00" s="" dp="2" ah="0" d="0" dt="3" cv="1.00" ae="0" celldate="1/9/2019" controltype="etbl"
          timetype="reg" hasdatarec="1"&gt;
          &lt;nobr&gt;1.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="26557391-224c-48e5-87a3-bf002793f4e0" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/10/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" ct="1.00" s="" dp="2" ah="0" d="0" dt="0" cv="1.00" timetype="total" othours="0.00" reghours="1.00"&gt;
          &lt;nobr&gt;1.00&lt;/nobr&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr id="718f6602-c9fe-4cb1-a309-e8342c34a0f2" style="height: 25px;" s="" pid="d9aca3f0-04ae-44ee-94f0-c2ed14da8e24"&gt;
        &lt;td align="left" ct="10.00" s="" dp="2" ah="0" d="0" dt="0" cv="10.00" timetype="RemainHrs"&gt;
          &lt;nobr&gt;10.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="left" ct="0.00" s="" dp="2" ah="0" d="0" dt="0" cv="0.00" timetype="PerComp"&gt;
          &lt;nobr&gt;0.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="1/7/2019" align="center" ct="1/7/2019" s="" dp="2" ah="0" d="0" dt="4" cv="1/7/2019" timetype="ForecastFinish"&gt;
          &lt;nobr&gt;1/7/2019&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="57e0de52-1114-4532-8088-5902d01005e2" style="background-color: rgb(238, 238, 238);" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/4/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="ca52dd3e-52a3-4139-80be-ef7cbdd533dc" style="background-color: rgb(238, 238, 238);" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/5/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="62d73cbd-ede0-4043-b8ae-4d43cc65c8f4" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/6/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="Description: &amp;#10;&amp;#13;OT hours: 0.00&amp;#10;&amp;#13;Is work performed Onsite?: &amp;#10;&amp;#13;Technical Activity Bucket: &amp;#10;&amp;#13;Is this Travel time?: &amp;#10;&amp;#13;" align="right" class="r" id="4db5269d-1512-4236-a2f2-6fb51c5a3892" style="color: rgb(0, 128, 0);"
          ct="10.00" s="" dp="2" ah="0" d="0" dt="3" cv="10.00" ae="0" celldate="1/7/2019" controltype="etbl" timetype="reg" hasdatarec="1"&gt;
          &lt;nobr&gt;10.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="Task for Karin Goren" align="right" id="3c124199-04fb-4f04-841b-cef8f6c7fece" ct="4.00" s="" dp="2" ah="0" d="0" dt="3" cv="4.00" ae="1" celldate="1/8/2019" controltype="etbl" timetype="reg" hasdatarec="1"&gt;
          &lt;nobr&gt;4.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="Task for Karin Goren" align="right" id="ee7f0b68-98d1-440c-a801-98d432a3d322" ct="5.00" s="" dp="2" ah="0" d="0" dt="3" cv="5.00" ae="1" celldate="1/9/2019" controltype="etbl" timetype="reg" hasdatarec="1"&gt;
          &lt;nobr&gt;5.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="784f3cf3-b9ad-43ca-9ea8-99e7384f78de" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/10/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" ct="19.00" s="" dp="2" ah="0" d="0" dt="0" cv="19.00" timetype="total" othours="0.00" reghours="19.00"&gt;
          &lt;nobr&gt;19.00&lt;/nobr&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr id="e2437d6b-db12-4ec2-9724-d21e84171c18" style="height: 25px;" s="" pid="d9aca3f0-04ae-44ee-94f0-c2ed14da8e24"&gt;
        &lt;td align="left" ct="10.00" s="" dp="2" ah="0" d="0" dt="0" cv="10.00" timetype="RemainHrs"&gt;
          &lt;nobr&gt;10.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="left" ct="0.00" s="" dp="2" ah="0" d="0" dt="0" cv="0.00" timetype="PerComp"&gt;
          &lt;nobr&gt;0.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="1/7/2019" align="center" ct="1/7/2019" s="" dp="2" ah="0" d="0" dt="4" cv="1/7/2019" timetype="ForecastFinish"&gt;
          &lt;nobr&gt;1/7/2019&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="ed31f3c4-a5c6-4d79-ad8a-9d5debdd20dc" style="background-color: rgb(238, 238, 238);" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/4/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="4e26eafe-f2fb-4005-9ff5-190b436ce5e4" style="background-color: rgb(238, 238, 238);" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/5/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="a3cc1439-c20c-4568-afd5-62b407379da8" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/6/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="442c6007-7ed3-43ef-a29f-a659a3fa82bf" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/7/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="63972eb3-9de2-4a1b-9b41-4d0a7ff6bf28" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/8/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="Task for Karin Goren" align="right" id="6e87f65e-6f14-4992-9e78-ec1785188c23" ct="3.00" s="" dp="2" ah="0" d="0" dt="3" cv="3.00" ae="1" celldate="1/9/2019" controltype="etbl" timetype="reg" hasdatarec="1"&gt;
          &lt;nobr&gt;3.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="93041572-96b4-43aa-a261-6ba53bccb519" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/10/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" ct="3.00" s="" dp="2" ah="0" d="0" dt="0" cv="3.00" timetype="total" othours="0.00" reghours="3.00"&gt;
          &lt;nobr&gt;3.00&lt;/nobr&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr id="f6b76a38-f33f-4ecc-8c33-99e061877560" style="height: 25px;" s="" pid="bd3bedb4-dbba-4132-a61c-7357765eb80d"&gt;
        &lt;td align="left" ct="20.00" s="" dp="2" ah="0" d="0" dt="0" cv="20.00" timetype="RemainHrs"&gt;
          &lt;nobr&gt;20.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="left" ct="0.00" s="" dp="2" ah="0" d="0" dt="0" cv="0.00" timetype="PerComp"&gt;
          &lt;nobr&gt;0.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="1/7/2019" align="center" ct="1/7/2019" s="" dp="2" ah="0" d="0" dt="4" cv="1/7/2019" timetype="ForecastFinish"&gt;
          &lt;nobr&gt;1/7/2019&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="5161894a-6047-442c-9896-e81f90230238" style="background-color: rgb(238, 238, 238);" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/4/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="0f7cb1c2-67ae-4c75-b094-dd083911d1c9" style="background-color: rgb(238, 238, 238);" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/5/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="d11cc9dd-6f21-4a43-acbd-de48224df366" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/6/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" id="ce4ef478-1b4d-436a-97dd-66fcffca6611" ct="" s="" dp="2" ah="0" d="0" dt="3" cv="" ae="1" celldate="1/7/2019" controltype="etbl" timetype="reg" hasdatarec="0"&gt;
          &lt;nobr&gt;&amp;nbsp;&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="Description: &amp;#10;&amp;#13;OT hours: 0.00&amp;#10;&amp;#13;Is work performed Onsite?: &amp;#10;&amp;#13;Technical Activity Bucket: &amp;#10;&amp;#13;Is this Travel time?: &amp;#10;&amp;#13;" align="right" class="r" id="d0151d04-d2f1-4413-b6bb-d3560f95c0f5" style="color: rgb(128, 128, 144);"
          ct="1.00" s="" dp="2" ah="0" d="0" dt="3" cv="1.00" ae="0" celldate="1/8/2019" controltype="etbl" timetype="reg" hasdatarec="1"&gt;
          &lt;nobr&gt;1.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="Description: &amp;#10;&amp;#13;OT hours: 0.00&amp;#10;&amp;#13;Is work performed Onsite?: &amp;#10;&amp;#13;Technical Activity Bucket: &amp;#10;&amp;#13;Is this Travel time?: &amp;#10;&amp;#13;" align="right" class="r" id="aba659f1-57dc-4dbd-b7ef-263a0b020da7" style="color: rgb(128, 128, 144);"
          ct="2.00" s="" dp="2" ah="0" d="0" dt="3" cv="2.00" ae="0" celldate="1/9/2019" controltype="etbl" timetype="reg" hasdatarec="1"&gt;
          &lt;nobr&gt;2.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td title="Test task overlapping hours" align="right" id="9da306a8-b813-46ff-b94f-45636f401ba8" ct="1.00" s="" dp="2" ah="0" d="0" dt="3" cv="1.00" ae="1" celldate="1/10/2019" controltype="etbl" timetype="reg" hasdatarec="1"&gt;
          &lt;nobr&gt;1.00&lt;/nobr&gt;
        &lt;/td&gt;
        &lt;td align="right" ct="4.00" s="" dp="2" ah="0" d="0" dt="0" cv="4.00" timetype="total" othours="0.00" reghours="4.00"&gt;
          &lt;nobr&gt;4.00&lt;/nobr&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="https://i.stack.imgur.com/uw2Lv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uw2Lv.jpg" alt="UI and HTML"></a></p>