ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple "With" commands - Please help (https://www.excelbanter.com/excel-programming/313322-multiple-commands-please-help.html)

Azza

Multiple "With" commands - Please help
 
HELP

I have a screen full of comboboxes and when I initiate the form I want
to populate the drop downs.
I want to populate many of them with the same info but cannot work out
the WITH commands to populate many boxes with the same info.

i.e. With cboxDay1,cboxDay2
.add ("1")
.add ("2")
End With

- This command does not work

Please help

Dave Peterson[_3_]

Multiple "With" commands - Please help
 
You could loop through all the comboboxes and set each individually, or you
could just set one and "copy" to the others.

I put 6 comboboxes (cboxday1 through cboxday6) on a worksheet:

Dim iCtr As Long
With Worksheets("sheet1")
With .OLEObjects("cboxday1").Object
.Clear
.AddItem 1
.AddItem 2
.AddItem 3
End With
For iCtr = 2 To 6
.OLEObjects("cboxday" & iCtr).Object.List _
= .OLEObjects("cboxday1").Object.List
Next iCtr
End With

Azza wrote:

HELP

I have a screen full of comboboxes and when I initiate the form I want
to populate the drop downs.
I want to populate many of them with the same info but cannot work out
the WITH commands to populate many boxes with the same info.

i.e. With cboxDay1,cboxDay2
.add ("1")
.add ("2")
End With

- This command does not work

Please help


--

Dave Peterson



All times are GMT +1. The time now is 11:58 PM.

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