Trying to paste data from a website into excel into correct format

Sundance_Kid

Board Regular
Joined
Sep 2, 2017
Messages
155
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I am trying to copy and paste the data from the below link into excel, in the same format as in the website.

I want to capture the Result Date and the Draw Result. I would like it in the same format, with each number under Draw Result being in a stand alone cell.

However, the numbers appear vertically and I want them to appear horizontally. I want to capture the full years details in one copy and paste motion.

Any ideas how I can do this?



Thanks

Paste Issue Excel.PNG
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I understand that you've got already some code which extract it. Issue is that it shows these numbers incorrectly. If you show your code it can be easier to fix it instead of writing full web scraping code.
 
Upvote 0
Meantime...
This code:


Excel Formula:
Public Sub GetTable()
    Dim html As MSHTML.HTMLDocument, hTable As Object, ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    Set html = New MSHTML.HTMLDocument  
    With CreateObject("MSXML2.XMLHTTP")
        .Open "GET", "https://www.irishlottery.com/daily-million-archive-2020", False
        .send
        html.body.innerHTML = .responseText
    End With
    Set hTable = html.getElementsByClassName("table lotto archiveTable")(0)
    Dim td As Object, tr As Object, th As Object, r As Long, c As Long, li As Object
    For Each tr In hTable.getElementsByTagName("tr")
        r = r + 1: c = 1
        For Each th In tr.getElementsByTagName("th")
            ws.Cells(r, c) = th.innerText
            c = c + 1
        Next
        For Each td In tr.getElementsByTagName("td")
            ball = 0
            For Each li In td.getElementsByTagName("li")
                ws.Cells(r, c + ball) = li.innerText
                ball = ball + 1
            Next
            c = c + 1
        Next
    Next
End Sub
gives this:

Book1
ABCDEFGH
1Result Date:Draw Result:
2
3December 31st 2020 - 9:00pm 26925263830
4December 31st 2020 - 2:00pm 1102227323717
5December 30th 2020 - 9:00pm 18920373812
Sheet1
 
Upvote 0
I understand that you've got already some code which extract it. Issue is that it shows these numbers incorrectly. If you show your code it can be easier to fix it instead of writing full web scraping code.
Hey, many thanks for your reply.

I actually do not have any code I am using (well not intentionally). All I was literraly doing was highlighting the data in the website, right clicking, selecting copy and going into excel and basically right clicking and I am presented with two paste options - 1) Keep Source Formatting or 2) Match Destination Formatting.

There is also a paste special option but that just gives the option to paste as HTML, Unicode Text or Text.

So, I am trying to figure out is there a way to paste it in like you have in your second message and like I showed in my original message.

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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