简体   繁体   中英

Excel VBA: how can I change the value in ComboBox before populating PDF (view detail)

I am trying to build an automation tool to read inputs from a master data file with numerous cases, and for each case, do the necessary calculations and produce a report.

But, there are a few ComboBox in the input fields.

The calculation is based on the value in the ComboBox, and a report is created based on the output of the calc. It appears that the value in the ComboBox is updated now and so the calculation is actually correct using the correct input. BUT, when the PDF report is populated, it shows the initial value in the ComboBox, not the desired correct new input. And I see the ComboBox value is changed to the correct input AFTER the PDF is populated. This creates a problem as I have the correct outputs but misleading inputs in my reports. Is there any way I can have the value in the ComboBox changed BEFORE the PDF is populated?

Sheet7.ComboBox1.Value = "No"

This does not work for me.....

Private Sub CommandButton1_Click()
    Dim sh As Worksheet
    Set sh = Sheets("Sheet1")
    sh.ComboBox1.Value = "Run"

End Sub

But this does work for me...

Private Sub CommandButton1_Click()

    Sheets("Sheet1").ComboBox1.Value = "Run"

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM