Exporting a Query to a Spreadsheet

grovelli
4StarLounger
Posts: 528
Joined: 26 Jan 2010, 15:14

Re: Exporting a Query to a Spreadsheet

Post by grovelli »

Thanks again for your heads-up, in any case, without your magic piece of code, even the accdb version still doesn't produce the correct results in the ProdvsBDG-mese sheet.

grovelli
4StarLounger
Posts: 528
Joined: 26 Jan 2010, 15:14

Re: Exporting a Query to a Spreadsheet

Post by grovelli »

I have a similar problem of recalculation for the formula in cell F22 on the Nomi sheet of the linked Stat.xlsx in that, once you press the Previous Month button on the startup form of the accdb from the link above, the formula =+MONTH(qt!A2) returns 1 while it should be 3.
I've tried to solve it by reusing your magic code
' For Each cel In xlSheet.UsedRange.SpecialCells(xlCellTypeFormulas)
' cel.Formula = cel.Formula
' Next cel
but this time I get the message, "No cells were found"

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Exporting a Query to a Spreadsheet

Post by HansV »

You're trying to run this code on the qt sheet:

Code: Select all

    Set xlSheet = xlBook.Sheets("qt")
    xlSheet.Columns("A:A").EntireColumn.AutoFit
    Dim cel As Range
    For Each cel In xlSheet.UsedRange.SpecialCells(xlCellTypeFormulas)
        cel.Formula = cel.Formula
    Next cel
But that sheet doesn't contain any formulas. You can use the code for ProdvsBDG-mese (which you already do) and for Nomi (which you don't).
Best wishes,
Hans

grovelli
4StarLounger
Posts: 528
Joined: 26 Jan 2010, 15:14

Re: Exporting a Query to a Spreadsheet

Post by grovelli »

:bash: :thankyou: