Good chance that with 50 checkboxes, these are on a worksheet rather than a
userform. In that case, you would use
Sub chngVal(x as Long)
Worksheets("Sheet1").OleObjects("CheckBox" & x).Object.Value = True
end sub
Assumes checkboxes from the control toolbox toolbar located on a worksheet
named Sheet1 with names like CheckBox1 to CheckBox50
--
Regards,
Tom Ogilvy
"Martin Fishlock" <(E-Mail Removed)> wrote in message
news:FB12D578-B0EA-499C-9E76-(E-Mail Removed)...
> Try using me.controls("CheckBox" & x ).Value = True
>
> --
> Hope this helps
> Martin Fishlock, Bangkok, Thailand
> Please do not forget to rate this reply.
>
>
> "(E-Mail Removed)" wrote:
>
>> Hi,
>>
>> I have 50 Check Boxes and I'm trying to create a Sub that accepts an
>> Integer parameter (1-50) and then changes the value of the check box to
>> true.
>>
>> This is the code that I'm trying to do
>>
>> Sub chngVal(x)
>> Dim thestring As String
>> thestring = "CheckBox" & x & ".Value = True"
>> thestring
>> End Sub
>>
>> So if I called chngVal(25), it would call CheckBox25.Value = True.
>>
>> This code doesn't work but is there a way to create a String or some
>> form of Object and then call the line?
>>
>> Thanks!
>>
>> Ilan
>>
>>
|