How to copy/paste from Web to Excel using VBA?

default1

New Member
Joined
Nov 13, 2012
Messages
1
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!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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