Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controls Toolbox Gene Augustin Excel Discussion (Misc queries) 0 October 10th 09 03:40 PM
Control Toolbox Controls spIky haIred Excel Programming 0 August 24th 05 08:13 AM
Controls Toolbox control vs Form Toolbox control Tony_VBACoder Excel Programming 3 January 28th 05 08:30 AM
Additional toolBox controls Soniya[_2_] Excel Programming 1 January 10th 04 06:40 AM
Additional ToolBox Controls Patrick Molloy Excel Programming 0 September 4th 03 07:42 AM


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"