Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 65
Default Combo Box - Crashing for Excel 97 users

Hi

I am using the following code to enable the use of a combo box. However
people using Excel 97 get an error message and then they must exit the
program when they press enter or tab to exit the field.

Any suggestions on code that will work on 97 and later versions would be
appreciated.

Code

Private Sub Invest_KeyDown(ByVal _
KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
'Hide combo box and move to next cell on Enter and Tab
Select Case KeyCode
Case 9
ActiveCell.Offset(0, 1).Activate
Case 13
ActiveCell.Offset(1, 0).Activate
Case Else
'do nothing
End Select

End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Dim wsList As Worksheet
Set ws = ActiveSheet
Set wsList = Sheets("Review Portfolio")
Cancel = True
Set cboTemp = ws.OLEObjects("Invest")
On Error Resume Next
With cboTemp
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
On Error GoTo errHandler
If Target.Validation.Type = 3 Then
Application.EnableEvents = False
str = Target.Validation.Formula1
str = Right(str, Len(str) - 1)
With cboTemp
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 15
.Height = Target.Height + 5
.ListFillRange = str
.LinkedCell = Target.Address
End With
cboTemp.Activate
End If

errHandler:
Application.EnableEvents = True
Exit Sub

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet
Application.EnableEvents = False
Application.ScreenUpdating = False

If Application.CutCopyMode Then
'allows copying and pasting on the worksheet
GoTo errHandler
End If

Set cboTemp = ws.OLEObjects("Invest")
On Error Resume Next
With cboTemp
.Top = 10
.Left = 10
.Width = 0
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
.Value = ""
End With

errHandler:
Application.ScreenUpdating = False
Application.EnableEvents = True
Exit Sub

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
Excel Crashing [email protected] Excel Discussion (Misc queries) 1 December 10th 07 02:23 PM
Crashing of Excel FASB Excel Discussion (Misc queries) 1 June 5th 07 04:32 PM
Excel 2003 keeps crashing Delbert Excel Discussion (Misc queries) 0 December 12th 05 06:35 PM
Help--Excel keeps crashing [email protected] Excel Discussion (Misc queries) 1 September 7th 05 10:22 PM
excel crashing robin Excel Discussion (Misc queries) 6 August 3rd 05 02:15 PM


All times are GMT +1. The time now is 06:44 AM.

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

About Us

"It's about Microsoft Excel"