Combobox Print Macro - Value in Combobox won't update

mweb23

New Member
Joined
Apr 28, 2010
Messages
4
I have a command button which I want to change the value in the Combobox then print. I only have 2 regions (USA, Intl). The problem is that the combobox value updates, but the text within the combobox does not.

Here's what I have:

Sub PrintLines()
With Sheet1.Combobox4
.Value = "USA"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End With

With Sheet1.Combobox4
.Value = "International"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End With
End Sub

The combobox is within the print range, but when the value changes to "International" the numbers in the report update (all vlookups off the linked cell "M4") , but the text within the combobox still says "USA."

How do I get the text within the combobox to update also?

Thanks.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try moving your Print Commands outside your With statements:
Code:
Sub PrintLines()
With ActiveSheet.ComboBox4
    .Value = "USA"
End With

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    
    'Pause to allow printing to begin
    Application.Wait (Now + TimeValue("00:00:02"))

With ActiveSheet.ComboBox4
    .Value = "International"
End With

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

End Sub
Also a slight pause between print commands allows screen updates to occur.
 
Upvote 0
Thanks for the reply, but no luck. The combobox still reads "USA" both times. I had tried putting a application.screenupdating = True earlier, but that didn't work either. I changed the time I waited to 20 seconds and still nothing.
 
Upvote 0
Try adding another pause between the International statement and the second PrintOut.
Code:
Sub PrintLines()
With ActiveSheet.ComboBox4
    .Value = "USA"
End With

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    
    'Pause to allow printing to begin
    Application.Wait (Now + TimeValue("00:00:02"))

With ActiveSheet.ComboBox4
    .Value = "International"
End With

Application.Wait (Now + TimeValue("00:00:02"))

ActiveSheet.PrintOut Copies:=1, Collate:=True

End Sub

You stated in your first post that the ComboBox did not change to "International", is that still the case?
 
Upvote 0
FYI...if it's an activeX combobox (like mine is), you need to activate the combobox to get it to update. So the code will look like this:

Sub PrintLines()
With Sheet1.Combobox4
.Value = SheetName.Cells(x,y).Value
.Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End With

With Sheet1.Combobox4
.Value = SheetName.Cells(x,y).Value
.Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End With
End Sub
 
Upvote 0
The code you posted does not show a change of value for ComboBox4.
Both ".Value" lines show "SheetName.Cells(x,y).Value".
Whatever x and y values are is not in the code.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,858
Members
449,051
Latest member
excelquestion515

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