Allow conditional formatting to update before continuing with rest of code?

Warwiz

New Member
Joined
Dec 4, 2017
Messages
6
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
 
Re: Excel - How do I allow conditional formatting to update before continuing with rest of code?

Conditional formatting is done in the worksheet.
A date column where cells are conditionally formatted Red or yellow or left unformatted - based on criteria dates in cells
1st condition - Cell value - between $V$1 and $W$1 = Yellow fill
2nd condition - Cell value - less than =$W$1 = Red fill
Cell criteria is - Cell $V$1 =now()-60 and cell $W$1 = now()-90

Table is then sorted
- first by date column color so red at top, then yellow, then unformatted.
- Then 2 other columns
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Re: Excel - How do I allow conditional formatting to update before continuing with rest of code?

What if in the VBA all conditional formatting is deleted & then created as the last step before the printing?

If not, what about fully explaining the situation so someone might be able to help?
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top