Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default web query in excel

I have some macros that pulls in data from a web site. the macros updates
the url, there is one for everyday with price information. However, every
time i run the macro it creates a range "ExternalData_#" with the number
representing the number of time the website has been queried. Some of the
workbook have over 500 ExternalData_# ranges this slows the whole thing down.

Does anyone know how to stop creation of a new range each time?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default web query in excel

I'm not sure if this is the most correct way to go on this, but this is what
I typically put in my query procedures after the query has been run:

Assume query table is in Sheet1 and query table name is MyQuery:

'***************
'Beginning of Code
'***************
On Error Resume Next
For Each rngRef In Sheet1.Names
If Left(rngRef.Name, 16) = "Sheet1!MyQuery_" Then
rngRef.Delete
End If
Next rngRef
On Error GoTo 0

On Error Resume Next
For Each tblRef In Sheet1.QueryTables
If Left(tblRef.Name, 8) = "MyQuery_" Then
tblRef.Delete
End If
Next tblRef
On Error GoTo 0
'***************
'End of Code
'***************

Note: I edited the code a bit to make it more generic, so you may have to
tweak it.

Does that help?

***********
Regards,
Ron


"JimEl" wrote:

I have some macros that pulls in data from a web site. the macros updates
the url, there is one for everyday with price information. However, every
time i run the macro it creates a range "ExternalData_#" with the number
representing the number of time the website has been queried. Some of the
workbook have over 500 ExternalData_# ranges this slows the whole thing down.

Does anyone know how to stop creation of a new range each time?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default web query in excel

Thanks Ron

It worked fine. The only problem was that the if(left...) statement was
case sensitive.

"Ron Coderre" wrote:

I'm not sure if this is the most correct way to go on this, but this is what
I typically put in my query procedures after the query has been run:

Assume query table is in Sheet1 and query table name is MyQuery:

'***************
'Beginning of Code
'***************
On Error Resume Next
For Each rngRef In Sheet1.Names
If Left(rngRef.Name, 16) = "Sheet1!MyQuery_" Then
rngRef.Delete
End If
Next rngRef
On Error GoTo 0

On Error Resume Next
For Each tblRef In Sheet1.QueryTables
If Left(tblRef.Name, 8) = "MyQuery_" Then
tblRef.Delete
End If
Next tblRef
On Error GoTo 0
'***************
'End of Code
'***************

Note: I edited the code a bit to make it more generic, so you may have to
tweak it.

Does that help?

***********
Regards,
Ron


"JimEl" wrote:

I have some macros that pulls in data from a web site. the macros updates
the url, there is one for everyday with price information. However, every
time i run the macro it creates a range "ExternalData_#" with the number
representing the number of time the website has been queried. Some of the
workbook have over 500 ExternalData_# ranges this slows the whole thing down.

Does anyone know how to stop creation of a new range each time?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default web query in excel

Thanks for the feedback.

Regarding the case sensitivity, you could probably just use a variation of
this:
If Ucase(Left(rngRef.Name, 16)) = Ucase("Sheet1!MyQuery_") Then

(You probably alread did that, though.)


***********
Regards,
Ron


"JimEl" wrote:

Thanks Ron

It worked fine. The only problem was that the if(left...) statement was
case sensitive.

"Ron Coderre" wrote:

I'm not sure if this is the most correct way to go on this, but this is what
I typically put in my query procedures after the query has been run:

Assume query table is in Sheet1 and query table name is MyQuery:

'***************
'Beginning of Code
'***************
On Error Resume Next
For Each rngRef In Sheet1.Names
If Left(rngRef.Name, 16) = "Sheet1!MyQuery_" Then
rngRef.Delete
End If
Next rngRef
On Error GoTo 0

On Error Resume Next
For Each tblRef In Sheet1.QueryTables
If Left(tblRef.Name, 8) = "MyQuery_" Then
tblRef.Delete
End If
Next tblRef
On Error GoTo 0
'***************
'End of Code
'***************

Note: I edited the code a bit to make it more generic, so you may have to
tweak it.

Does that help?

***********
Regards,
Ron


"JimEl" wrote:

I have some macros that pulls in data from a web site. the macros updates
the url, there is one for everyday with price information. However, every
time i run the macro it creates a range "ExternalData_#" with the number
representing the number of time the website has been queried. Some of the
workbook have over 500 ExternalData_# ranges this slows the whole thing down.

Does anyone know how to stop creation of a new range each time?

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
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 1 November 29th 05 01:44 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 0 November 28th 05 06:37 PM
Edit Query from Excel will not open query in MSQuery Michelle Excel Programming 0 February 21st 05 03:59 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


All times are GMT +1. The time now is 02:21 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"