ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cant find Control (https://www.excelbanter.com/excel-programming/356926-cant-find-control.html)

Todd Huttenstine

Cant find Control
 
Below is a code that programmatically adds an optionbutton to a
userform. This code works fine but when I try to retrieve all the
names of every control, the optionbutton shows up as 0. Its like it
does not have a name.

Dim OB_PriceKPI As MSForms.OptionButton
' Adds New Labels
Set OB_PriceKPI =
KPIWizard.Controls.Add("forms.optionbutton.1", Visible)
With OB_PriceKPI
.Name = "OB_PriceKPI"
.Width = 100
.Height = 18.75
.Left = 36
.Top = 60
'.AutoSize = True
.Font.Size = 8
.Font.Bold = True
.Caption = "Price"
End With

The optionbutton should be called "OB_PriceKPI" as I have specified in
the above code.
Below is the code I use to bring back all the names of every control on
my userform:
For Each ctl In Me.Controls
MsgBox ctl.Name
Next


Last, here is what I am trying to test for with the optionbutton, but
everytime it gets to the If statement, I get an error saying object
required. Again, its like the button does not exist but I just created
it with the 1st code.

Select Case Level
Case 1
If OB_PriceKPI.Value = True Then
KPITargetType = "PP"
Else
KPITargetType = "Feature"
End If
Case Else
End Select



Can anyone help me?



All times are GMT +1. The time now is 04:14 AM.

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