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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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.
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

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