Hi,
I'm new at the forum.
I'm having trouble to get the right command to copy content from a website and paste it in Excel using VBA.
I already tried the "Data -> import data from Web", but it only work in some cases. There are websites that doesn't allow this command.
So,
I already know how to access a website using VBA.
My doubts here are:
- how to select content from website (I'm also having trouble to recognize the name of the desired fields in the 'Source Code')
- how to copy the selected contents
- how to paste it in Excel
Everything using Macro (VBA).
Here's my Macro to access websites:
Sub Accesswebsite()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "Google"
ie.Visible = True
While ie.Busy
Wend
End Sub
Here's some of the command I've tried to select content from website, NONE of them have worked:
ie.Document.all.Select
or
ie.Document.All.Item(2).Select
or
ie.Document.All.Item("name_of_the_field").Select
Here's the command I intend to use to copy the information once I've selected the desired content from the website: (still haven't been able to try and see if the command I have works)
Selection.Copy
Here's the command I intend to use to paste information in Excel: (still haven't been able to try and see if the command I have works)
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues
I would appreciate very much if you could help me.
Thanks in advance!
I'm new at the forum.
I'm having trouble to get the right command to copy content from a website and paste it in Excel using VBA.
I already tried the "Data -> import data from Web", but it only work in some cases. There are websites that doesn't allow this command.
So,
I already know how to access a website using VBA.
My doubts here are:
- how to select content from website (I'm also having trouble to recognize the name of the desired fields in the 'Source Code')
- how to copy the selected contents
- how to paste it in Excel
Everything using Macro (VBA).
Here's my Macro to access websites:
Sub Accesswebsite()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "Google"
ie.Visible = True
While ie.Busy
Wend
End Sub
Here's some of the command I've tried to select content from website, NONE of them have worked:
ie.Document.all.Select
or
ie.Document.All.Item(2).Select
or
ie.Document.All.Item("name_of_the_field").Select
Here's the command I intend to use to copy the information once I've selected the desired content from the website: (still haven't been able to try and see if the command I have works)
Selection.Copy
Here's the command I intend to use to paste information in Excel: (still haven't been able to try and see if the command I have works)
Sheets("Sheet1").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues
I would appreciate very much if you could help me.
Thanks in advance!