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

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.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,351
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,711
Messages
5,855,264
Members
431,717
Latest member
Ibyb

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