Checkbox Caption

Dman333

Board Regular
Joined
Sep 30, 2016
Messages
52
Office Version
  1. 365
Platform
  1. Windows
I'm fairly new to VBA and have created a checkbox userform and want the caption for each checkbox to be the text in a cell in the worksheet. I keep seeing this line of code and copied it directly into the Userform_Click routine and it won't work. Any help with what I'm doing worng?

Private Sub UserForm_Click()
UserForm1.CheckBox1.Caption = Sheets("Sheet1").Range("A1").Value
End Sub

Any help is appreciated - Thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Correction - Its under
Private Sub PASelectForm_Initialize()
 
Upvote 0
Thanks for the response. This one's on me. While waiting for a response I tried it on a new workbook which is the first post and then copied from the one I'm actually working with.

I got it to work and then did what I really wanted below:

Sub UserForm_Initialize()
'This changes the Captions on the buttons to match the row


Dim I As Integer


For I = 3 To 22
Me.Controls("CboxRow" & I).Caption = ThisWorkbook.Sheets("Sheet3").Cells(I + 1, 2).Value
Next I




End Sub

It worked for a while and then stopped. It seems like there's a setting or switch that seems off or missing. It doesn't seem to like the -- ("CboxRow" & I) -- part because it's stopping there and giving a script out of range error and it's dead at the period before Caption.
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,545
Members
449,089
Latest member
davidcom

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