Hi
I request your valuable help
I have the following code:
Private Sub Worksheet_SelectionChange (ByVal Target As Range)
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr
Set xWs = Application.ActiveSheet
On Error Resume Next
If Target.Validation.Type = 3 Then
Target.Validation.InCellDropdown = False
Cancel = True
xStr = Target.Validation.Formula1
xStr = Right (xStr, Len (xStr) - 1)
If xStr = "" Then Exit Sub
Set xCombox = xWs.OLEObjects ("TempCombo")
With xCombox
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
With xCombox
.Visible = False
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 3
.Height = Target.Height + 3
.ListFillRange = xStr
If .ListFillRange = "" Then
xArr = Split (xStr, ",")
Me.TempCombo.List = xArr
End If
.LinkedCell = Target.Address
End With
xCombox.Activate
Me.TempCombo.DropDown
End If
End Sub
Private Sub TempCombo_KeyDown (ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Select Case KeyCode
Case 9
Application.ActiveCell.Offset (0, 1) .Activate
Case 13
Application.ActiveCell.Offset (1, 0) .Activate
End Select
End Sub
It works excellent, the only detail is that the combobox listing appears randomly throughout the sheet.
Is there a way for the list to appear in the selected cell without modifying anything else in the code?
Thank you
I request your valuable help
I have the following code:
Private Sub Worksheet_SelectionChange (ByVal Target As Range)
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr
Set xWs = Application.ActiveSheet
On Error Resume Next
If Target.Validation.Type = 3 Then
Target.Validation.InCellDropdown = False
Cancel = True
xStr = Target.Validation.Formula1
xStr = Right (xStr, Len (xStr) - 1)
If xStr = "" Then Exit Sub
Set xCombox = xWs.OLEObjects ("TempCombo")
With xCombox
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
With xCombox
.Visible = False
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 3
.Height = Target.Height + 3
.ListFillRange = xStr
If .ListFillRange = "" Then
xArr = Split (xStr, ",")
Me.TempCombo.List = xArr
End If
.LinkedCell = Target.Address
End With
xCombox.Activate
Me.TempCombo.DropDown
End If
End Sub
Private Sub TempCombo_KeyDown (ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Select Case KeyCode
Case 9
Application.ActiveCell.Offset (0, 1) .Activate
Case 13
Application.ActiveCell.Offset (1, 0) .Activate
End Select
End Sub
It works excellent, the only detail is that the combobox listing appears randomly throughout the sheet.
Is there a way for the list to appear in the selected cell without modifying anything else in the code?
Thank you