rahulsteel
New Member
- Joined
- Apr 3, 2019
- Messages
- 11
I have the below VBA coding on 3 of my sheets in an excel workbook. My excel crases after few minutes, can someone suggest if there is anything wrong with the coding
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Sheet1.DTPicker1
DTPicker1.Value = Format(DTPicker1.Value, "mm/dd/yyyy")
.Height = 20
.Width = 20
If Not Intersect(Target, Range("B:B")) Is Nothing Then
.Visible = True
.Top = Target.Top
.Left = Target.Offset(0, 1).Left
.LinkedCell = Target.Address
Else
.Visible = False
End If
End With
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
Set ws = ActiveSheet
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
'clear and hide the combo box
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
On Error GoTo errHandler
If Target.Validation.Type = 3 Then
'if the cell contains
'a data validation list
Cancel = True
Application.EnableEvents = False
'get the data validation formula
str = Target.Validation.Formula1
str = Right(str, Len(str) - 1)
With cboTemp
'show the combobox with the list
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 5
.Height = Target.Height + 5
.ListFillRange = str
.LinkedCell = Target.Address
End With
cboTemp.Activate
'open the drop down list automatically
Me.Tempcombo.DropDown
End If
errHandler:
Application.EnableEvents = True
Exit Sub
End Sub
Last edited by a moderator: