maxipoblete
New Member
- Joined
- Jan 27, 2022
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
- MacOS
Hello,
I want to create 2 dependent dropdown lists (form contorl) with VBA.
Listadesplegable1: The first dropdown list selects between 4 different cases.
Listadesplegable5: The second dropdown list selects the different options of each case.
Here's the code:
"Sub Listadesplegable1_Cambiar()" is just in the Change() of Dropdownlist1 in spanish btw.
The problem is that when i change the first dropdown list, the second doesn't update...
The macro works fine on .xls but not in .xlsm
Thanks!
I want to create 2 dependent dropdown lists (form contorl) with VBA.
Listadesplegable1: The first dropdown list selects between 4 different cases.
Listadesplegable5: The second dropdown list selects the different options of each case.
Here's the code:
VBA Code:
Option Explicit
Sub Listadesplegable1_Cambiar()
Dim num As Single
Dim i, j As Integer
Dim k, m As Integer
Dim condicion1, condicion2, condicion3 As Boolean
num = Worksheets("I|O").Range("C13")
condicion1 = True
condicion2 = True
condicion3 = True
i = 1
j = 1
k = 7
m = 7
With Worksheets("I|O").DropDowns("Lista desplegable 5")
.ListFillRange = " "
Select Case num
Case 1
Do While condicion1
.List(i) = Worksheets("Perfiles H ICHA 2001").Cells(k, 1).Value
If Worksheets("Perfiles H ICHA 2001").Cells(k + 1, 1) = 0 Then
condicion1 = False
End If
i = i + 1
k = k + 1
Loop
Case 2
Do While condicion2
.List(j) = Worksheets("Perfiles H AISC").Cells(m, 1).Value
If Worksheets("Perfiles H AISC").Cells(m + 1, 1) = 0 Then
condicion2 = False
End If
j = j + 1
m = m + 1
Loop
Case 3
.ListFillRange = "Especial"
Case 4
Do While condicion3
.List(i) = Worksheets("Perfiles H ICHA 2008").Cells(k, 1).Value
If Worksheets("Perfiles H ICHA 2008").Cells(k + 1, 1) = 0 Then
condicion3 = False
End If
i = i + 1
k = k + 1
Loop
End Select
End With
End Sub
"Sub Listadesplegable1_Cambiar()" is just in the Change() of Dropdownlist1 in spanish btw.
The problem is that when i change the first dropdown list, the second doesn't update...
The macro works fine on .xls but not in .xlsm
Thanks!