Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default What wrong with defined variable?

Does anyone have any suggestions what wrong is the variable - Mywebsite on
following coding? The url cannot be assigned into Mywebsite variable.

Does anyone have any suggestions?
Thank you very much for any suggestions
Eric

Dim Mywebsite As String
Set Mywebsite = "http://www.stata.com/help.cgi?macro"

With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;" & Mywebsite & """", Destination:=Sheets("Temp").Range("$A$1"))
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default What wrong with defined variable?

Instead of:
Set Mywebsite = "http://www.stata.com/help.cgi?macro"
use:
Mywebsite = "http://www.stata.com/help.cgi?macro"
--
Gary''s Student - gsnu200773
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default What wrong with defined variable?

Thank you very much for your suggestion
Do you have any suggestions on following error? and do you have any
suggestions on how to fix it?
Thank you very much for any suggestions
Eric

[Working]
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=1",
Destination:=Sheets("Temp").Range("$A$1"))

[Not working]
Mywebsite = 1
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=" &
Mywebsite & """", Destination:=Sheets("Temp").Range("$A$1"))

Error pointing to
..Refresh BackgroundQuery:=False


"Gary''s Student" wrote:

Instead of:
Set Mywebsite = "http://www.stata.com/help.cgi?macro"
use:
Mywebsite = "http://www.stata.com/help.cgi?macro"
--
Gary''s Student - gsnu200773

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default What wrong with defined variable?

I don't see:
..Refresh BackgroundQuery:=False

in the post
--
Gary''s Student - gsnu200773


"Eric" wrote:

Thank you very much for your suggestion
Do you have any suggestions on following error? and do you have any
suggestions on how to fix it?
Thank you very much for any suggestions
Eric

[Working]
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=1",
Destination:=Sheets("Temp").Range("$A$1"))

[Not working]
Mywebsite = 1
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=" &
Mywebsite & """", Destination:=Sheets("Temp").Range("$A$1"))

Error pointing to
.Refresh BackgroundQuery:=False


"Gary''s Student" wrote:

Instead of:
Set Mywebsite = "http://www.stata.com/help.cgi?macro"
use:
Mywebsite = "http://www.stata.com/help.cgi?macro"
--
Gary''s Student - gsnu200773

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default What wrong with defined variable?

I forget the error has been fixed. Based on both following queries, the first
one can load the code for 1, but the second one cannot do it.
Do you have any suggestions on what wrong it is and how to solve it?
Thank you very much for your reply and suggestions
I look forward to your reply
Eric

[Can load the code = 1]
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=1",
Destination:=Sheets("Temp").Range("$A$1"))

[Cannot load the code = 1]
Mywebsite = 1
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=" &
Mywebsite & """", Destination:=Sheets("Temp").Range("$A$1"))


"Gary''s Student" wrote:

I don't see:
.Refresh BackgroundQuery:=False

in the post
--
Gary''s Student - gsnu200773


"Eric" wrote:

Thank you very much for your suggestion
Do you have any suggestions on following error? and do you have any
suggestions on how to fix it?
Thank you very much for any suggestions
Eric

[Working]
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=1",
Destination:=Sheets("Temp").Range("$A$1"))

[Not working]
Mywebsite = 1
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=" &
Mywebsite & """", Destination:=Sheets("Temp").Range("$A$1"))

Error pointing to
.Refresh BackgroundQuery:=False


"Gary''s Student" wrote:

Instead of:
Set Mywebsite = "http://www.stata.com/help.cgi?macro"
use:
Mywebsite = "http://www.stata.com/help.cgi?macro"
--
Gary''s Student - gsnu200773



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default What wrong with defined variable?

It seems to me that the query for url has been changed if the URL is combined
together. Do you have any suggestions on what wrong the url is by combining
Mywebsite to form the query.
Thank you very much for suggestions
Eric

[Can load the code = 1]
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=1",
Destination:=Sheets("Temp").Range("$A$1"))

[Cannot load the code = 1]
Mywebsite = 1
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=" &
Mywebsite & """", Destination:=Sheets("Temp").Range("$A$1"))


"Gary''s Student" wrote:

I don't see:
.Refresh BackgroundQuery:=False

in the post
--
Gary''s Student - gsnu200773


"Eric" wrote:

Thank you very much for your suggestion
Do you have any suggestions on following error? and do you have any
suggestions on how to fix it?
Thank you very much for any suggestions
Eric

[Working]
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=1",
Destination:=Sheets("Temp").Range("$A$1"))

[Not working]
Mywebsite = 1
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=" &
Mywebsite & """", Destination:=Sheets("Temp").Range("$A$1"))

Error pointing to
.Refresh BackgroundQuery:=False


"Gary''s Student" wrote:

Instead of:
Set Mywebsite = "http://www.stata.com/help.cgi?macro"
use:
Mywebsite = "http://www.stata.com/help.cgi?macro"
--
Gary''s Student - gsnu200773

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default What wrong with defined variable?

This is the way to insert your variable. In this case the variable has to be
a number
If you need additional help on a project, you may contact me privately. I am
a retired series 7 stockbroker.
I do this sort of thing for my clients on a daily basis. You really don't
want to ADD a new connecition. What you want to do is REFRESH an existing
with the variable. Or, variables in a loop.

mycode = 3

With ActiveSheet.QueryTables.Add(Connection:="URL;" & _
"http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=" _
& mycode, Destination:=Range("A5"))
'As I said earlier, you must have this line
.Refresh BackgroundQuery:=False

End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Eric" wrote in message
...
It seems to me that the query for url has been changed if the URL is
combined
together. Do you have any suggestions on what wrong the url is by
combining
Mywebsite to form the query.
Thank you very much for suggestions
Eric

[Can load the code = 1]
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=1",
Destination:=Sheets("Temp").Range("$A$1"))

[Cannot load the code = 1]
Mywebsite = 1
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=" &
Mywebsite & """", Destination:=Sheets("Temp").Range("$A$1"))


"Gary''s Student" wrote:

I don't see:
.Refresh BackgroundQuery:=False

in the post
--
Gary''s Student - gsnu200773


"Eric" wrote:

Thank you very much for your suggestion
Do you have any suggestions on following error? and do you have any
suggestions on how to fix it?
Thank you very much for any suggestions
Eric

[Working]
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode=1",
Destination:=Sheets("Temp").Range("$A$1"))

[Not working]
Mywebsite = 1
With Sheets("Temp").QueryTables.Add(Connection:= _
"URL;http://www.quamnet.com/quote.action?quoteSectionCode=&stockCode="
&
Mywebsite & """", Destination:=Sheets("Temp").Range("$A$1"))

Error pointing to
.Refresh BackgroundQuery:=False


"Gary''s Student" wrote:

Instead of:
Set Mywebsite = "http://www.stata.com/help.cgi?macro"
use:
Mywebsite = "http://www.stata.com/help.cgi?macro"
--
Gary''s Student - gsnu200773


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
Variable sum from defined input David Excel Worksheet Functions 7 March 10th 09 06:26 AM
variable not defined Carlee Excel Programming 2 April 26th 07 08:56 PM
variable not defined, ActiveWorkbook.name Janis Excel Programming 1 September 1st 06 08:30 PM
Can Step through but when run defines variable wrong sportzrule Excel Programming 1 August 30th 06 07:33 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM


All times are GMT +1. The time now is 10:17 PM.

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

About Us

"It's about Microsoft Excel"