I have code that runs multiple query's from the same Excel table and after each query is ran it saves it as a PDF file.
The code works great but on the larger query's it doesn't allow the conditional formatting to update before creating the PDF.
I have tried may ways of getting it to update the formatting using calculate, scroll off screen and back, wait function, doEvents etc with no success.
DoEvents allowed the smaller query's to update before saving but not the larger ones (even though I am probably not using it right)
I tried searching for a solution but there isn't much on this topic that I could find.
Maybe someone here can help?(oh and I am a very novice VBA'er .. trial, error, n google)
Using office 365 pro
After the query is ran, How do I allow time for any conditional formatting to update before performing the PDF save?
'Query1
Range("MATER_DISPO[#All]").AdvancedFilter Action _
:=xlFilterInPlace, CriteriaRange:=Range("AB1:AB2"), Unique:=False
Worksheets("Pending").Calculate
DoEvents
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="H:\Development" & Format(Date, "yyyy-mmm-dd") & Range("AB3").Value
'Query2
Range("MATER_DISPO[#All]").AdvancedFilter Action _
:=xlFilterInPlace, CriteriaRange:=Range("AC1:AC2"), Unique:=False
Worksheets("Pending").Calculate
DoEvents
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="H:\Development" & Format(Date, "yyyy-mmm-dd") & Range("AB3").Value
The code works great but on the larger query's it doesn't allow the conditional formatting to update before creating the PDF.
I have tried may ways of getting it to update the formatting using calculate, scroll off screen and back, wait function, doEvents etc with no success.
DoEvents allowed the smaller query's to update before saving but not the larger ones (even though I am probably not using it right)
I tried searching for a solution but there isn't much on this topic that I could find.
Maybe someone here can help?(oh and I am a very novice VBA'er .. trial, error, n google)
Using office 365 pro
After the query is ran, How do I allow time for any conditional formatting to update before performing the PDF save?
'Query1
Range("MATER_DISPO[#All]").AdvancedFilter Action _
:=xlFilterInPlace, CriteriaRange:=Range("AB1:AB2"), Unique:=False
Worksheets("Pending").Calculate
DoEvents
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="H:\Development" & Format(Date, "yyyy-mmm-dd") & Range("AB3").Value
'Query2
Range("MATER_DISPO[#All]").AdvancedFilter Action _
:=xlFilterInPlace, CriteriaRange:=Range("AC1:AC2"), Unique:=False
Worksheets("Pending").Calculate
DoEvents
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="H:\Development" & Format(Date, "yyyy-mmm-dd") & Range("AB3").Value