ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop through values in a combobox (https://www.excelbanter.com/excel-programming/376094-loop-through-values-combobox.html)

rael_lucid

Loop through values in a combobox
 
Hi,

I have a spreadsheet which has a combobox and a table of data below it. When
a value in the combobox is selected, the data below changes. I would like to
write a routine that basically selects each value in the combobox and then
prints the page.

So, something like:

For Each <variable in <Combobox
ActiveWorkbook.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
Next <variable

Is this possible?
If the combo box has 100 items, do I run the risk of crashing the PC, or
printer?
Is there a better way?

Rael

Bob Phillips

Loop through values in a combobox
 
Presumably the combobox is sourced from some other data? You could always
loop through that data.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rael_lucid" wrote in message
...
Hi,

I have a spreadsheet which has a combobox and a table of data below it.

When
a value in the combobox is selected, the data below changes. I would like

to
write a routine that basically selects each value in the combobox and then
prints the page.

So, something like:

For Each <variable in <Combobox
ActiveWorkbook.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
Next <variable

Is this possible?
If the combo box has 100 items, do I run the risk of crashing the PC, or
printer?
Is there a better way?

Rael




rael_lucid

Loop through values in a combobox
 
Bob,

Have converted the Combobox to a Listbox and used the following code:

Dim iCount As Long

With Me.lstCentres
For iCount = 0 To .ListCount - 1
.Selected(iCount) = True
If iCount 0 Then .Selected(iCount - 1) = False
Application.DisplayAlerts = False
ActiveWorkbook.PrintOut From:=1, To:=2, Copies:=1, Collate:=True
Application.DisplayAlerts = True
Next iCount
End With

"Bob Phillips" wrote:

Presumably the combobox is sourced from some other data? You could always
loop through that data.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rael_lucid" wrote in message
...
Hi,

I have a spreadsheet which has a combobox and a table of data below it.

When
a value in the combobox is selected, the data below changes. I would like

to
write a routine that basically selects each value in the combobox and then
prints the page.

So, something like:

For Each <variable in <Combobox
ActiveWorkbook.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
Next <variable

Is this possible?
If the combo box has 100 items, do I run the risk of crashing the PC, or
printer?
Is there a better way?

Rael






All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com