ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checkboxes (https://www.excelbanter.com/excel-programming/364152-checkboxes.html)

Robbyn

Checkboxes
 
Greetings! Why am I getting the "Object doesn't support this property or
method" error on the following code:

For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
n = n + 1
If ctrl.Value Then
.Offset(0, n).Value = Chr(82) <------Error
End If
End If
Next ctrl

TIA


Tom Ogilvy

Checkboxes
 
because you don't have a With statement with a valid object identified that
has an Offset property.

Perhaps

With ActiveCell
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
n = n + 1
If ctrl.Value Then
.Offset(0, n).Value = Chr(82)
End If
End If
Next ctrl
End With



--
Regards,
Tom Ogilvy

"Robbyn" wrote:

Greetings! Why am I getting the "Object doesn't support this property or
method" error on the following code:

For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
n = n + 1
If ctrl.Value Then
.Offset(0, n).Value = Chr(82) <------Error
End If
End If
Next ctrl

TIA


Robbyn

Checkboxes
 
Hi Tom. I had with statement but I found a silly error. Your example helped
me find it. Thank you much.

"Tom Ogilvy" wrote:

because you don't have a With statement with a valid object identified that
has an Offset property.

Perhaps

With ActiveCell
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
n = n + 1
If ctrl.Value Then
.Offset(0, n).Value = Chr(82)
End If
End If
Next ctrl
End With



--
Regards,
Tom Ogilvy

"Robbyn" wrote:

Greetings! Why am I getting the "Object doesn't support this property or
method" error on the following code:

For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
n = n + 1
If ctrl.Value Then
.Offset(0, n).Value = Chr(82) <------Error
End If
End If
Next ctrl

TIA



All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com