Data update problem

BKNewton29

New Member
Joined
Sep 17, 2010
Messages
30
Dear All,

I have a spreadsheet that dynamically changes ODBC data based on picking an item from a drop down menu.

I have now created a VB code to cycle through each branch on the drop down menu and print the resulting Profit and Loss to PDF.

However, the print to PDF command doesn't give the data enough time to auto refresh the data and resultant Profit and Loss.

Is there any way I can slow down the VB to allow the data to update?

current code set out below (Q is the column were branch numbers are plucked from)



Sub PrinttoPDF()
' Set variables used in Macro
Dim c As Range, strDefaultPrinter As String, strOutFile As String, branchname As String
strDefaultPrinter = Application.ActivePrinter
Application.ActivePrinter = "CutePDF Writer on CPW2:"
Application.ScreenUpdating = False
With Sheets("Branch Profit and Loss")

' pick each branch number from the list in column S
For Each c In .Range("Q1", .Range("Q1").End(xlDown))
' change the branch value in the drop down menu for each branch
.Range("C2").Value = c.Value
' recalculate once branch number has changed
Dim uniquename As String
' rename the filename after each branch ready for PDF export
uniquename = Range("R2").Value
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"H:\Accounts\2011\AXA Reporting\Branch Reports\" & uniquename & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Next c
End With
Application.ScreenUpdating = True
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,551
Messages
6,179,476
Members
452,915
Latest member
hannnahheileen

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