Results 1 to 6 of 6
  1. #1
    ry94080 is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2019
    Posts
    29

    Export Query to Excel w/ Formula

    Hello all,

    I have a query that is basically exporting a count of items to Excel. I was wondering if it was possible to export to excel which would include a formula in a cell. So that the user of the report could enter a value into the excel and automatically do a simple calculation.

    My query is as follows:

    SELECT LV_UNQ.OrderCode, Count(LV_UNQ.OrderCode) AS CountOfOrderCode, 0 AS HoursWorked, "=C2/B2" AS Calculation
    FROM LV_UNQ
    WHERE (((LV_UNQ.FirstOfResultDate)>=Date()-1))
    GROUP BY LV_UNQ.OrderCode, 0, "=C2/B2"
    HAVING (((LV_UNQ.OrderCode)="Test"));



    However, when it is exported to Excel, the formula column is not "recognized" as a formula.

    Below is what the Excel export looks like:
    OrderCode Count HoursWorked Calculation
    Test 594 0 =C2/B2

    I'm hoping the end user can enter a value into HoursWorked and that the Calculation would auatomatically calculate.

    I'm open to any ideas. Thanks

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    How are you exporting to Excel? If using TransferSpreadsheet method I think that to do this from Access side you'd have to use automation. Whatever method you're using, it appears your expression is being interpreted as a string, not a formula. Check Excel cell to see if an apostrophe was prepended, and check the cell format.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    You cannot export formulas.

  4. #4
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,041
    You can export the data to an excel workbook and then use VBA to open the workbook and add the formula.

  5. #5
    Join Date
    Apr 2017
    Posts
    1,679
    Why don't you have simply a SQL query in Excel workbook, which reads data from your Access DB? You can set the query to be run when the workbook is opened, and additionally Excel user can activate the query at any time manually. And you can have additional columns at right of query datarange, which are automatically updated whenever the query is running. All this without any code needed.

  6. #6
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    You could also bring the query into Excel using Power Query. Once set up, everytime you select refresh all, it will update in excel based upon the current values in the Access query.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 05-19-2021, 02:38 AM
  2. Replies: 1
    Last Post: 10-18-2019, 06:09 AM
  3. Replies: 19
    Last Post: 07-13-2015, 10:15 AM
  4. Replies: 41
    Last Post: 05-29-2015, 02:58 PM
  5. Excel Formula into Access Query
    By dr4ke in forum Queries
    Replies: 7
    Last Post: 06-25-2012, 06:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums