Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Past to cell instead of a msg box

0

Hi,

How can I change the code to past the result to a cell instead of a msg box.

Thank you!

******************

Sub Import_SpecificData()

Dim request As Object

Dim response As String

Dim html As New HTMLDocument

Dim website As String

Dim total As Variant

website = "https://www.morningstarfunds.ie/ie/funds/snapshot/snapshot.aspx?id=F00000LLUO"

Set request = CreateObject("MSXML2.XMLHTTP")

request.Open "GET", website, False

request.setRequestHeader "If-Modified-Since", "Mon, 14 Nov 2022 00:00:00 GMT"

request.send

response = StrConv(request.responseBody, vbUnicode)

html.body.innerHTML = response

total = html.getElementsByClassName("line text")(0).innerText

MsgBox total

End Sub

Answer
Discuss

Discussion

Hi Henrik. Did you try my Answer? 
John_Ru (rep: 6092) Nov 29, '22 at 8:17 am
Add to Discussion

Answers

0

Hi Henrik and welcome to the Forum 

To put the result in cell A1 say, replace the line:

MsgBox total

with:

Range("A1").Value = total

Change A1 to the cell you want (on the active sheet). 

Hope this helps. If so, please remember to mark this Answer as Selected. 

Discuss

Discussion

Hi Henrik- did that work for you? If so, please mark the Answer as Selected.
John_Ru (rep: 6092) Dec 15, '22 at 7:23 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login