Finding the last used cell in Excel
<p>Anyone knows how to check if the cell contains a data using VBScript? Because of what I have seen, it's a bit differrent from VBA. I have tried this code but is not working:</p>

<pre><code>Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\test\test.xlsx")
Set user = CreateObject("WScript.Network")
logname = user.Username

objExcel.Application.Visible = True

If Hour(Now) &gt;= 1 And Hour(Now) =&lt; 11 Then
    WScript.Echo "Good Morning"
    WScript.Echo "Log Record is:", Time, Date

    lastrow = Range("A1").End(xlDown).Row
    Cells(lastrow+1, 1).Value = logname
End If
</code></pre>

<p>After checking if the row contains a data, the code will insert data to the next row that doesn't contain a data. We'll say: if <code>CELL A1</code> has a data, then <code>CELL A2</code> is empty, then the data to be inserted will be inserted in <code>CELL A2</code>.</p>

<p>Please note that I'm working on <a href="/questions/tagged/vbscript" class="post-tag" title="show questions tagged &#39;vbscript&#39;" rel="tag">vbscript</a>, not <a href="/questions/tagged/vba" class="post-tag" title="show questions tagged &#39;vba&#39;" rel="tag">vba</a>.</p>