Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Creating event procedure on worksheet

i create a combo box when the user select a cell in a certain range
i want to create an event(change event) so the combo box will have
items
when the user clicks on the combobox...
i inserted some lines in the selection_change and an error "subscript
out of range"
was shown when I add the event..i can't go debug mode because
of the creation of the combo box inside my class...please help me solve
it.....

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim obj As OLEObject
Dim objCombo As ComboBox 'Object

For Each obj In ActiveSheet.OLEObjects
If obj.Name = "cmbDPS" Then obj.Delete
Next
'when beyond DPS column was selected the combobox was still
'created up to the extent of the width of the selected cell
If Not Intersect(Target, Range("DPS")) Is Nothing Then

Call AutoCom.KeyEventOff
Set obj = InsDPS.CreateDropDown(Target)
Set objCombo = obj.Object
'
'ActiveSheet.OLEObjects(obj.Object.Name).Change
Dim StartLine As Long
Dim ws As Worksheet
Set ws = ActiveSheet


With ActiveWorkbook.VBProject.VBComponents(ws.Name).Cod eModule
StartLine = .CreateEventProc("Change", "cmbDPS") '+ 1
.InsertLines StartLine, _
"Msgbox ""Hello World"",vbOkOnly"
End With
Else
AutoCom.KeyEventOn
End If



If AutoCom.GetValidation Then
AutoCom.GetPrevCell.Validation.Delete
AutoCom.LetValidation = False
End If

AutoCom.LetNewCellFlag = True

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
Validation Procedure with a worksheet change event Bhupinder Rayat Excel Worksheet Functions 2 October 3rd 07 05:18 PM
Creating An Event Procedure Les Stout[_2_] Excel Programming 4 October 4th 05 02:03 PM
Creating an event procedure question bhofsetz[_6_] Excel Programming 2 June 8th 05 07:03 PM
Running Event Procedure When Cell Updated on Excel Worksheet Tom Ogilvy Excel Programming 0 August 19th 04 03:38 PM
Using VBA to track changes in a worksheet - help! Event procedure?? a Excel Programming 7 June 24th 04 01:36 PM


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

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"