Move to the next blank cell

klatlap

Well-known Member
Joined
Sep 1, 2004
Messages
607
Office Version
  1. 2013
Platform
  1. Windows
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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
gees, all i had to do was change RowNum = 2 to RowNum = RowNum +1
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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
Back
Top