loop forms and input code

JMCruyff

New Member
Joined
Sep 7, 2006
Messages
1
Hi - let me join this forum with 2 possibly stupid questions (I've tried the search, but haven't been successful):

- quite often I have userforms with many controls which I need to fill, e.g.
UserForm.ComboBox1.Value = a(1)
UserForm.ComboBox2.Value = a(2)
UserForm.ComboBox3.Value = a(3)
which I would like to do in a loop - something like:
for i=1 to 3:UserForm.ComboBox(i).Value = a(i):next i
which is not possible.
Any way around the multi-line way?

- I am using an excel 'template' which various macros (forms, moduels), which I want to update from time to time.
I don't want to rely on add-ins, knowing that the various users cannot be "trusted" to carry the add-in between computers.
So I would like to send an excel around which (after selecting the xls-file) updates (deletes old ones, copies/imports new ones) the forms and modules of the selected xls-file.
Any idea?

Thanks a lot
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,286
Office Version
  1. 365
Platform
  1. Windows
Well for your first question.
Code:
For I = 1 To 3
    Me.Controls("ComboBox" & I) = a(I)
Next I
And for your 2nd perhaps this link will help Programming to the VBE, with the deleting modules/code anyway.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,187
Messages
5,640,693
Members
417,161
Latest member
Devon150

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
Top