range problem with code

jek40

Active Member
Joined
Jan 17, 2005
Messages
317
I have a button on sheet2 and would like to copy the table from this website and paste it on sheet1. how could i change the line of code below to paste to sheet1 range L1. I I cant seem to come up with something that will work. (the rest of my code is ok -- I just cant seem to get by this line -- it wants to paste to sheet2)

thanks for any help

John


Code:
With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.xxxxxxxx.com/table1.htm", Destination:=Range("L1"))
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
Hi John,

If you push a button on Sheet2 and don't qualify the reference, VBA assumes that you want to paste to the same sheet. Try:
Code:
With ActiveSheet.QueryTables.Add(Connection:= _ 
        "URL;http://www.xxxxxxxx.com/table1.htm", Destination:=Sheets("Sheet1").Range("L1"))
Denis
 

Forum statistics

Threads
1,172,019
Messages
5,878,759
Members
433,370
Latest member
mcleven

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
Top