stephendeman
Gebruiker
- Lid geworden
- 14 dec 2017
- Berichten
- 28
Beste Allemaal,
Kort vraagje; Ik heb in een document meerdere comboboxen die transponeren in de cel erachter. Echter als ik bijvoorbeeld Combobox1 invul en dan naar Combobox2 ga en hetzelfde doe en, daarna terug moet naar Combobox1 zie ik de code van Combobox2 en niet van 1. Ik ben absoluut geen VBA pro dus ik heb werkelijk geen idee waar dit aan ligt, waarschijnlijk heeft dit een zeer simpele oorzaak. Wellicht iets met vastzetten etc. Alvast dank!
De code is nu als volgt:
Private Sub ComboBox2_Change()
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr
Set xWs = Application.ActiveSheet
On Error Resume Next
Set xCombox = xWs.OLEObjects("ComboBox2")
With xCombox
.ListFillRange = "Opleiding"
.LinkedCell = "$C$10:$H$10"
.Visible = True
End With
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
With xCombox
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 5
.Height = Target.Height + 5
.ListFillRange = xStr
If .ListFillRange = "Opleiding" Then
xArr = Split(xStr, ",")
Me.ComboBox2.List = xArr
End If
.LinkedCell = Target.Address
End With
xCombox.Activate
Me.ComboBox2.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
Kort vraagje; Ik heb in een document meerdere comboboxen die transponeren in de cel erachter. Echter als ik bijvoorbeeld Combobox1 invul en dan naar Combobox2 ga en hetzelfde doe en, daarna terug moet naar Combobox1 zie ik de code van Combobox2 en niet van 1. Ik ben absoluut geen VBA pro dus ik heb werkelijk geen idee waar dit aan ligt, waarschijnlijk heeft dit een zeer simpele oorzaak. Wellicht iets met vastzetten etc. Alvast dank!
De code is nu als volgt:
Private Sub ComboBox2_Change()
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr
Set xWs = Application.ActiveSheet
On Error Resume Next
Set xCombox = xWs.OLEObjects("ComboBox2")
With xCombox
.ListFillRange = "Opleiding"
.LinkedCell = "$C$10:$H$10"
.Visible = True
End With
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
With xCombox
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 5
.Height = Target.Height + 5
.ListFillRange = xStr
If .ListFillRange = "Opleiding" Then
xArr = Split(xStr, ",")
Me.ComboBox2.List = xArr
End If
.LinkedCell = Target.Address
End With
xCombox.Activate
Me.ComboBox2.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