If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > How to open MSQuery in a macro in Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-21-04, 16:50
Wim Venema Wim Venema is offline
Registered User
 
Join Date: Jun 2004
Location: Lichtenvoorde, Netherlands
Posts: 53
How to open MSQuery in a macro in Excel (NOT SOLVED YET!!)

How to open MSQuery in a macro in Excel, creating a query
and return the result in a worksheet.

Last edited by Wim Venema; 09-22-04 at 07:55.
Reply With Quote
  #2 (permalink)  
Old 09-22-04, 02:30
Bud Bud is offline
Registered User
 
Join Date: Dec 2003
Location: Dallas, TX
Posts: 995
Quote:
Originally Posted by Wim Venema
How to open MSQuery in a macro in Excel, creating a query
and return the result in a worksheet.

Hi,

Not exactly sure how to do that from scratch but my way of doing it would be to go to Tools/Macro/Record a new macro, then go to Data/GetExternalData/NewDatabaseQuery and create a Query to pull in your data from wherever. Then go into your Tools/Macro/VisualBasicEditor when done and in the VBE editor see the code for the macro. But like I stated, that's the way I would do it and have done it, but may not be the best. Mainly use Access so not all that keen on Excel. Hopefully someone will help you out with more expertise.

have a nice one,
Bud
Reply With Quote
  #3 (permalink)  
Old 09-22-04, 02:37
Wim Venema Wim Venema is offline
Registered User
 
Join Date: Jun 2004
Location: Lichtenvoorde, Netherlands
Posts: 53
Hello Bud,

Thanks for your response, but the problem is, that the macro recorder doesn't record the steps between opening MSQuery and showing the results.
The result exists only out of the QueryTables.Add command(s).
Reply With Quote
  #4 (permalink)  
Old 09-23-04, 10:06
cruickshanks cruickshanks is offline
Registered User
 
Join Date: Jul 2004
Location: Inverurie
Posts: 628
you can create a Dadabase query first, then record a macro to run it as bud said. simply go to Data/get External Data/Create Database Query and make it. once you have got what you need then save it.

Then record a new macro with you running the new query. It should then end up displaying the results every time you run the macro.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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