Cargar región y código cuidad según archivo adjunto

Para Dante Amor;

1 Respuesta

Respuesta
1

H o l a:

Tienes que describir con ejemplos lo que necesitas.

Disculpa Dante Amor

Ahora te explico lo que necesito:

Como ya se puede cargar la zona desde el archivo adjunto, ahora necesito saber como cargar región y código cuidad según la zona??

Tengo la base de datos y el excel adjunto en la misma carpeta y funciona sin problemas, pero me falta esta situacion

saludos

macontad

H o  l a:

Te anexo el código para cargar la región y el código

Public h1, h2
'
Private Sub ComboBox1_Change()
'Por.Dante Amor
    ComboBox2.Clear
    TextBox3 = ""
    If ComboBox1 = "" Or ComboBox1.ListIndex = -1 Then Exit Sub
    '
    Set b = h2.Rows(1).Find(ComboBox1, lookat:=xlWhole)
    If Not b Is Nothing Then
        For i = 2 To h2.Cells(Rows.Count, b.Column).End(xlUp).Row
            ComboBox2.AddItem h2.Cells(i, b.Column)
            ComboBox2.List(ComboBox2.ListCount - 1, 1) = h2.Cells(i, b.Column + 1)
        Next
    End If
End Sub
'
Private Sub ComboBox2_Change()
'Por.Dante Amor
    TextBox3 = ""
    If ComboBox2 = "" Or ComboBox2.ListIndex = -1 Then Exit Sub
    TextBox3 = ComboBox2.List(ComboBox2.ListIndex, 1)
End Sub
'
Private Sub UserForm_Activate()
'Por.Dante Amor
    Set l1 = ThisWorkbook
    Set h1 = l1.Sheets(1)
    abierto = False
    archivo = "excel adjunto.xlsx"
    ruta = l1.Path & "\"
    For Each libro In Workbooks
        If libro.Name = archivo Then
            abierto = True
            Exit For
        End If
    Next
    If abierto Then
        Set l2 = Workbooks(archivo)
    Else
        If Dir(ruta & archivo) <> "" Then
            Set l2 = Workbooks.Open(ruta & archivo)
        Else
            MsgBox "No está abierto el archivo y tampoco se puede abrir"
            Exit Sub
        End If
    End If
    Set h2 = l2.Sheets(1)
    '
    'Carga combo zona
    For i = 2 To h2.Range("A" & Rows.Count).End(xlUp).Row
        ComboBox1.AddItem h2.Cells(i, "A")
    Next
End Sub

'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas