Variable Label number in form code

Bradium

Board Regular
Joined
Oct 8, 2008
Messages
129
Hi Guys

I was wondering if it was possible to get a variable to change the reference to a the next label on a form. I would like to be able to select the next label without hard coding it if possible.

Example: Label1 then Label2 etc from "Label" & MyLabelNumber

I have had a go but to no avail.

On A user form I have 3 Labels.
In an Active cell I have: abc,def,ghi


Private Sub UserForm_Initialize()
Dim Arr1, Arr2
Dim i As Long
Dim MyLabelNumber As Long

Myname = ActiveCell.Value

Arr1 = Split(Myname, ",")

'MyLabelNumber = 1

'mytest = "Label" & MyLabelNumber

For i = LBound(Arr1) To UBound(Arr1)

Label1.Caption = Arr1(i)

'mytest.Caption = Arr1(i)
'MyLabelNumber = MyLabelNumber + 1

Next i

End Sub


Regards

Brad
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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