Move to the next blank cell

klatlap

Well-known Member
Joined
Sep 1, 2004
Messages
597
I know this is a simple one but i can't get the correct syntax, this macro prints URLs from table from a webpage, the problem is each new table starts in Row 2, what i need is for the first table to start in Row 2 but an new tables should start at the end of the last table printed.

I have used this in the past but can't make it work in this instance.

Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets("Sheet2").Range("A1").Value

Code:
Sub ProcessHTMLPage(HTMLPage As MSHTML.HTMLDocument)

    Dim HTMLTable As MSHTML.IHTMLElement
    Dim HTMLTables As IHTMLElementCollection
    Dim HTMLRow As MSHTML.IHTMLElement
    Dim HTMLCell As MSHTML.IHTMLElement
    Dim RowNum As Long, ColNum As Integer
    Dim i As Integer
    
 
    Set HTMLTables = HTMLPage.getElementsByTagName("Table")
    For Each HTMLTable In HTMLTables
      
            
        
        RowNum = 2
       
        For Each HTMLRow In HTMLTable.getElementsByTagName("tr")
            
            ColNum = 1
            For Each HTMLCell In HTMLRow.getElementsByTagName("a")
                Cells(RowNum, ColNum) = vbTab & HTMLCell.getAttribute("href")
                ColNum = ColNum + 1
            Next HTMLCell
            
            RowNum = RowNum + 1
            
        Next HTMLRow
      
       
       Next HTMLTable
 End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

klatlap

Well-known Member
Joined
Sep 1, 2004
Messages
597
gees, all i had to do was change RowNum = 2 to RowNum = RowNum +1
 

Watch MrExcel Video

Forum statistics

Threads
1,129,382
Messages
5,635,937
Members
416,889
Latest member
dhegs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top