Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Update a Web Query and be able to change the WebAddress manually from a specific Cell


Hi,
I use an Excel Macro which updates stock prices from the internet b
using the existing Web Query functionality in Excel. (Data = Impor
External Data= New Web Query) I use another macro to trigger the macr
(called: "UpdateWebPrices") below . Everything works fine and the price
are updated adn displayed nice and easy in the Excel sheet. So far s
god….

BUT:
I would like to be able to change the used Address (Web-Address
manually from a specific Cell in Excel – without having to go into th
Visual Basic Macro itself:

Example:
I would like to update different Stock prices from yahoo.com in m
Excel sheet. Each stock has a specific Quote name which is unique fo
every stock. For example the US company General Motor is called GM an
the company Google is called GOOG.

The Web-Address for the company General Motors
http://finance.yahoo.com/q?s=GM
The Web-Address for the company Googl
= http://finance.yahoo.com/q?s=GOOG

As seen in the two Web-addresses above the only difference is tha
General Motors has “GM” and Google “GOOG” in the end of eac
Web-address.

What I would like to do is:
1. Have a cell in Excel where I manually enter GM or GOOG etc. I ente
the text in for example the Cell “C1”

2. Click on a button which execute a Macro which then triggers th
following the Recorded Visual Basic Macro named “UpdateWebPrices”



Sub UpdateWebPrices()
Range("C1").Select
ActiveCell.FormulaR1C1 = "http://finance.yahoo.com/q?s=GM"
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q?s=GM"
Destination:=Range("D1"))
.Name = "Stock Price"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub



As seen in the recorded Macro above the Address is “hard-coded” a
http://finance.yahoo.com/q?s=GM and I would like to be able to chang
that address from a specific cell in my sheet. The manual work aroun
is of course to go into the WebQuery itself and change the Adres
manually – or go direct into the Visual Basic Module and manuall
change the URL from
"URL;http://finance.yahoo.com/q?s=GM", t
"URL;http://finance.yahoo.com/q?s=GOOG".

BUT:
The question is if it is possible to change the Web-address direct fro
a cell in Excel instead? I will use the function =CONCATENATE(A1;B1) i
Cell C1 to create the Web-Address itself.
The Sheet is built up with the following cells:

Example:
Cell A1:
Display the first part of the Address with the text:
http://finance.yahoo.com/q?s=

Cell B1:
Display the last part of the Address: for example the text GM or GOO
(This is the cell I would like to update by manually adding for exampl
GM

Cell C1:
Use the Excel function CONCATENATE (A1,B1) which display
http://finance.yahoo.com/q?s=GM

Cell D1:
Is the first Cell the Stock price data should be put into.


Does anyone know how this can be done please?
Many thanks in advance,
Sve

--
Sve
-----------------------------------------------------------------------
Sven's Profile: http://www.excelforum.com/member.php...nfo&userid=954
View this thread: http://www.excelforum.com/showthread.php?threadid=52453

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to update one manually-entered value from another? 1robc57 Excel Worksheet Functions 2 February 2nd 06 05:07 AM
I can only manually update? jclark419[_2_] Excel Programming 1 July 21st 05 05:48 PM
Manually Update Listindex DB Excel Programming 4 June 11th 05 04:37 AM
Manually update links Emma Excel Worksheet Functions 0 February 22nd 05 01:23 PM
Stop to modify the SQL query manually entered into query ! Olivier Rollet Excel Programming 6 November 3rd 04 08:34 AM


All times are GMT +1. The time now is 07:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"