Help with Frames in a Userform

Gilbfernandes

New Member
Joined
Jan 26, 2016
Messages
20
Hi everyone, I have a routine that runs more or less like this: In a Userform I have 30 Frames with CommandBotton inside. I want the routine to run From Range A1 to A30 of a sheet and if there is a 1 on that cell it means the cell is Active and the correspondent Frame on the USerForm should have a Capiton "Active".

I don’t want to do a IF-End IF lines checking the Cell and them changing the Frame Caption. If I do this I would have to have 30 lines, like
If Range(“a1”)=1 them Userform1.Frame1.Caption="Active"
.
.
.
I Would like to do something like:

For i = 1 to 30
If Range("a" & i)=1 them Userform1.Frame& i.Caption="Active"
Next i

I know this is not possible because I tried and there was an error, because of the attributes of Userform1.Frames
Does anyone have an idea?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Not sure why you have 30 frames, but try this.
Code:
For i = 1 to 30
    If Range("a" & i)=1 them Userform1.Controsl("Frame"& i).Caption="Active"
Next i
 
Upvote 0
Not sure why you have 30 frames, but try this.
Code:
For i = 1 to 30
    If Range("a" & i)=1 them Userform1.Controsl("Frame"& i).Caption="Active"
Next i

That was exactly what I need, Thank you very much. I have 30 frames because each one corresponds to a Button that must be pressed if that cell is active.
If you do not mind, do you know a good course to learn VBA and VB programming? I know the basic, but I would like to learn it all.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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