Friday, July 22, 2011

Adding Controls On Worksheet in RunTime :

If you need to Add Controls On Worksheet in Run Time :


Sub MakeComponentinRunTImeOnSpreadSheet()
On Error Resume Next
Dim cb As OLEObject
n = 5
For i = 1 To 10
 Set cb = ActiveSheet.OLEObjects.Add(classtype:="Forms.Checkbox.1")
                With cb
                    .Top = n
                    .Object.Caption = "Do you want to Select Range"
                    .LinkedCell = Active.Offset(0, 5).Address
                    .Object.Value = False
                    .Visible = True
                End With
                ActiveCell.Offset(1, 0).Activate
                Set cb = Nothing
                n = n + 20
Next
End Sub



No comments: