Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Location
    Haaksbergen, Netherlands
    Posts
    69

    Unanswered: 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 08:55.

  2. #2
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    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

  3. #3
    Join Date
    Jun 2004
    Location
    Haaksbergen, Netherlands
    Posts
    69
    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).

  4. #4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •