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

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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?
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,180
Members
448,871
Latest member
hengshankouniuniu

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