Changing data in the web address of a web query by input

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
I thought you said you had added a QueryTable, so I don't understand how you can't have one.
 

Some videos you may like

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"

ianccy

Active Member
Joined
Jul 28, 2002
Messages
332
if the data in this sheet01 cell A1 is link to the data in sheet02 A1, what is the code?

the previous code works only when a value is enter, now the data is linked to other sheet, how to get it working?
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Try this in the module for sheet02 (and delete the original code in sheet01):

Code:
Private Sub Worksheet_Change(ByVal Target As Range) 
   If Target.Address <> "$A$1" Then Exit Sub 
   With WorkSheets("sheet01").QueryTables(1) 
      .Connection = "URL;http://www.xxxxxxxx.com/Example/cgihistory.cgi?id=" & Range("A1").Value & "&begin=2001&end=2008" 
      .Refresh 
   End With 
End Sub
 

ianccy

Active Member
Joined
Jul 28, 2002
Messages
332
The code should be pasted to sheet 01?

and if my link is linked to sheet01 M1, what is the code?

thank you for the help
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
ianccy said:
The code should be pasted to sheet 01?

and if my link is linked to sheet01 M1, what is the code?

thank you for the help

The code goes in the sheet that contains the changing cell (the one you want to use in the Query Connection string). You need to adjust "$A$1" and Range("A1") to refer the changing cell, and WorkSheets("sheet01") to refer to the sheet containing the QueryTable.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,351
Messages
5,595,650
Members
414,006
Latest member
Davefromlondon

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