473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to use input box data?

I have recorded a macro that will use a web query to obtain the latest price of the microsoft (msft) stock. I want to use this macro to get data on other stocks. My thought is to use an input box that asks me to type in the ticker name. The macro will then use this input to obtain the latest price of whatever ticker i type in. I can't figure out how to put the input box data into the macro. In the macro below, I want to put X wherever the web query uses the ticker msft. My plan is to add a bunch of web queries to the macro so when I type in the ticker name into the input box, the macro will return financial sheets, rations, etc:

Sub Getquote()
'
' Getquote Macro
' Macro recorded 1/8/2011 by CLAY D
'
' Keyboard Shortcut: Ctrl+q
'

X = InputBox("enter ticker", "ticker name")

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q?s=msft", Destination:=Range("F27"))
.Name = "q?s=msft_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """table1"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
Jan 8 '11 #1
1 1903
I am not familiar with the web site you are querying so don't know the difference between the two msft references that I see in your code, however to include X this is how you would do it:

"URL;http://finance.yahoo.com/q?s=msft", Destination:=Range("F27"))
.Name = "q?s=msft_1"

"URL;http://finance.yahoo.com/q?s=" & X, Destination:=Range("F27"))
.Name = "q?s=" & X " & "_1"
Jan 13 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Grey | last post by:
I have created a asp.net form for user to input data. After input the data, user need to click a button to export the input data to excel for data analysis with excel pivot table function. is it...
2
by: Jim B | last post by:
I am new to VB.NET and have a question on validating user input from a Text Box. I'm writing a small program where I want to check the users input data and determine if it's an Integer or a...
2
by: Magnus | last post by:
I'm currently developing an application with classified information as input to a couple of algorithms. Which strategy should I use to protect the input data from beeing read? The files should...
17
by: stathis gotsis | last post by:
Hello everyone, I am tying to come up with an elegant way to process some input data that come from a form. When the user hits the 'Submit' button, i want the form to appear again with the...
1
by: JJ | last post by:
Is it possible to count the number of columns that match certain conditions and return a single value? For example in the database we have a record where: Column 1 = Male Column 2 = A Column...
4
by: jane007 | last post by:
Hello everybody: I am having a problem. On Unix platform, there is a script that need user to input data from console, then when I call Unix perl script from Windows, these is an issue occurs,...
0
by: Vyas111111 | last post by:
Hello all, I am working on ASP.net web service using C# i want to validate the input data , is there any way in the web service to validate the input data. Thanks in advance.
1
idsanjeev
by: idsanjeev | last post by:
how can check the input data is character or numeric if input data accept the numeric and input data is character then error message
8
idsanjeev
by: idsanjeev | last post by:
how can check the input data is character or numeric if input data accept the numeric and input data is character then error message
2
by: eko99312 | last post by:
Dear All, As you know that input data on excel is easy than access, you can simple click the date that you prefer and input the value that you want. For example : Consider that the month that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.