Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calling same event for all the toolbox controls in the sheet
How can i call the same event for all the toolbox controls in an excel
sheet. I have got a code from this site to call the same event if the controls are of same type. This is the code for calling the keydown event for textboxes. But is there a way I can use the same code for all the controls in the sheet(option button, textbox etc). 'in the workbook open Public C As Collection Set C = New Collection For Each Obj In Sheet1.OLEObjects If (TypeOf Obj.Object Is MSForms.TextBox) Then C.Add New Class1 With C(C.Count) Set .TB = Obj.Object Set .Object = Obj .Index = C.Count End With End If Next Obj ' in the class1 module Public WithEvents TB As MSForms.TextBox Dim I , TBCount As Integer Private Sub TB_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) If KeyCode < 9 Then Exit Sub TBCount = ThisWorkbook.C.Count If Shift Then If Index = 1 Then I = TBCount Else I = Index - 1 Else If Index = TBCount Then I = 1 Else I = Index + 1 End If ActiveWindow.RangeSelection.Select ThisWorkbook.C(I).Object.Activate End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Controls Toolbox | Excel Discussion (Misc queries) | |||
Control Toolbox Controls | Excel Programming | |||
Controls Toolbox control vs Form Toolbox control | Excel Programming | |||
Additional toolBox controls | Excel Programming | |||
Additional ToolBox Controls | Excel Programming |