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:
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
Because im using Excel in Spanish Language "Sub Listadesplegable1_Cambiar()" is the same as Change() of Dropdown List. I don't really know if that's an issue.
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!