Landzir101
Board Regular
- Joined
- Jun 21, 2009
- Messages
- 78
Fairly new to macros and I was how I would go about having a web query (that is executed by a button) execute on a separate worksheet than the active sheet it is on. This is a brief summary of what I am doing:
I have about a dozen worksheets that are formatted for a specific web query. On each page I have a macro assigned to a button. So, to get the data I go through each tab and click the button; it pulls the data through.
What I am wanting is a way to have the button separate from the worksheet (say on the main page) and be able to query all the data from that page. Not sure on the exact naming convention or way to do this. Thanks for the help!
Below is a little of the code so you can see what I am saying...
...
Sub Annual_Income_Statement()
Dim sSymbol As String
Dim sDestination As String
With ActiveSheet
.Range("B4:M200").ClearContents
sSymbol = .Range("B3").Value
sDestination = .Range("B3").Offset(2, 0).Address
With .QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q/is?s=" & sSymbol & "&annual", Destination:=Range(sDestination))
'.PostText = "Quote0=" & sSymbols
.Name = "Recent News " & sSymbol
I have about a dozen worksheets that are formatted for a specific web query. On each page I have a macro assigned to a button. So, to get the data I go through each tab and click the button; it pulls the data through.
What I am wanting is a way to have the button separate from the worksheet (say on the main page) and be able to query all the data from that page. Not sure on the exact naming convention or way to do this. Thanks for the help!
Below is a little of the code so you can see what I am saying...
...
Sub Annual_Income_Statement()
Dim sSymbol As String
Dim sDestination As String
With ActiveSheet
.Range("B4:M200").ClearContents
sSymbol = .Range("B3").Value
sDestination = .Range("B3").Offset(2, 0).Address
With .QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q/is?s=" & sSymbol & "&annual", Destination:=Range(sDestination))
'.PostText = "Quote0=" & sSymbols
.Name = "Recent News " & sSymbol