CAMBIO DE COMBOBOX POR TEXTBOX

1 post / 0 nuevos
SALAVERRINO
Imagen de SALAVERRINO
Offline
última acción: Hace 3 años 7 meses
alta: 24/05/2016 - 15:59
Puntos: 210
CAMBIO DE COMBOBOX POR TEXTBOX

Buenas tardes a los integrantes de este foro, en esta ocasión recurro nuevamente a uds, para que me brinde su apoyo y colaboración con la siguiente macro dentro del Formulario UserForm2, la descripción esta en cada imagen que se adjunta el archivo zipeador (IMAGENES), así también el archivo de la macro..

Private Sub ComboBox3_Change()
    Label10.Caption = Sheets("Config").Range("B" & ComboBox3.ListIndex + 2)
End Sub
Private Sub CommandButton1_Click()
    Sheets("Calendario1").Range("K16").Value = 1
    Load frmCalendary
    frmCalendary.Show
End Sub
Private Sub CommandButton2_Click()
    If TextBox1.Value = "" Or TextBox2.Value = "" Then
        MsgBox "Faltan datos"
    Else
        TextBox2.Enabled = False
        TextBox1.Enabled = False
        Label21.Enabled = False
        Frame2.Visible = True
        CommandButton1.Visible = False
        CommandButton2.Visible = False
        CommandButton5.Visible = False
        Label12.Caption = "CAPTURANDO"
    End If
ComboBox1.SetFocus
End Sub
Private Sub CommandButton3_Click()
    Dim FF As Integer
    With Sheets("Config")
 
If ComboBox1.Value = "" Or ComboBox2.Value = "" Or ComboBox3.Value = "" Then
        MsgBox "Faltan datos por Ingresar"
Else
    If Label12.Caption = "CAPTURANDO" Then
            If Val(Label8.Caption) < 16 Then
                .Range("J" & Val(Label8.Caption) + 2) = ComboBox3.Value         'dni 
                .Range("K" & Val(Label8.Caption) + 2) = Label10.Caption         'Nombre 
                .Range("L" & Val(Label8.Caption) + 2) = CDate(Day(CDate(TextBox1.Value)) & "/" & Month(CDate(TextBox1.Value)) & "/" & Year(CDate(TextBox1.Value)))  'fecha 
                .Range("M" & Val(Label8.Caption) + 2) = TextBox2.Value          'tONELAJE 
                .Range("N" & Val(Label8.Caption) + 2) = ComboBox1.Value          'TURNO 
                .Range("O" & Val(Label8.Caption) + 2) = ComboBox2.Value         'ESPECIALIDAD 
 
                If CheckBox1.Value = True Then
                    .Range("P" & Val(Label8.Caption) + 2) = "SI"
                End If
 
                If CheckBox2.Value = True Then
                    .Range("Q" & Val(Label8.Caption) + 2) = "SI"
                End If
 
 
                FF = Sheets("Config").Range("I1").Value + 1
                Frame3.Visible = True
                ListBox1.ColumnHeads = True
                ListBox1.RowSource = "Config!J2:Q" & FF
 
                Frame4.Visible = True
 
                Call Restablecer_Valores
 
                If Val(Label8.Caption) = 0 Then
                    Label8.Caption = 1
                Else
                    Label8.Caption = Val(Label8.Caption) + 1
                End If
 
            Else
                MsgBox "Para continuar exporte los datos"
            End If
        Else        'MODIFICANDO 
            .Range("J" & Val(Label14.Caption) + 1) = ComboBox3.Value         'dni 
            .Range("K" & Val(Label14.Caption) + 1) = Label10.Caption         'Nombre 
            .Range("L" & Val(Label14.Caption) + 1) = CDate(Day(CDate(TextBox1.Value)) & "/" & Month(CDate(TextBox1.Value)) & "/" & Year(CDate(TextBox1.Value)))  'fecha 
            .Range("M" & Val(Label14.Caption) + 1) = TextBox2.Value          'tONELAJE 
            .Range("N" & Val(Label14.Caption) + 1) = ComboBox1.Value          'TURNO 
            .Range("O" & Val(Label14.Caption) + 1) = ComboBox2.Value         'ESPECIALIDAD 
 
            If CheckBox1.Value = True Then
                .Range("P" & Val(Label14.Caption) + 1) = "SI"
                Else
                .Range("P" & Val(Label14.Caption) + 1) = ""
            End If
 
            If CheckBox2.Value = True Then
                .Range("Q" & Val(Label14.Caption) + 1) = "SI"
                Else
                .Range("Q" & Val(Label14.Caption) + 1) = ""
            End If
 
 
            FF = Sheets("Config").Range("I1").Value + 1
            ListBox1.ColumnHeads = True
            ListBox1.RowSource = "Config!J2:Q" & FF
 
            Call Restablecer_Valores
    End If
End If
End With
ComboBox1.SetFocus
End Sub
Private Sub CommandButton4_Click()
    Dim FILA, i As Integer
    FILA = Sheets("Config").Range("I2").Value + 2
With Sheets("Base")
        For i = 0 To ListBox1.ListCount - 1
            .Cells(FILA, 1).Value = ListBox1.List(i, 0)
            .Cells(FILA, 2).Value = ListBox1.List(i, 1)
            .Cells(FILA, 3).Value = ListBox1.List(i, 2)
            .Cells(FILA, 4).Value = ListBox1.List(i, 3)
            .Cells(FILA, 5).Value = ListBox1.List(i, 4)
            .Cells(FILA, 6).Value = ListBox1.List(i, 5)
            .Cells(FILA, 7).Value = ListBox1.List(i, 6)
            .Cells(FILA, 8).Value = ListBox1.List(i, 7)
            FILA = FILA + 1
        Next
    End With
 
    Sheets("Config").Range("J2:Q17").ClearContents
 
    Frame2.Visible = False
    Frame3.Visible = False
    Frame4.Visible = False
    TextBox2.Enabled = True
    TextBox1.Enabled = True
    CommandButton2.Visible = True
    CommandButton1.Visible = True
    CommandButton5.Visible = True
    Label8.Caption = Sheets("Config").Range("I1").Value
    TextBox1.Value = ""
    TextBox2.Value = ""
    MsgBox "Los datos fueron exportados a la base exitosamente!"
TextBox1.SetFocus
End Sub
Private Sub CommandButton5_Click()
Unload Me
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Dim i As Integer
 
    For i = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(i) = True Then
            ComboBox1.Value = ListBox1.List(i, 4)   'Turno 
            ComboBox2.Value = ListBox1.List(i, 5)   'Especialidad 
 
            If ListBox1.List(i, 6) = "SI" Then      'Permiso 
                CheckBox1.Value = True
            End If
 
            If ListBox1.List(i, 7) = "SI" Then      'Asig Familiar 
                CheckBox2.Value = True
            End If
 
 
            ComboBox3.Value = ListBox1.List(i, 0)   'DNI 
            Label10.Caption = ListBox1.List(i, 1)
            Label14.Caption = i + 1
        End If
    Next
 
    Label12.Caption = "MODIFICANDO"
    Label12.ForeColor = &HFF&
    Label13.Visible = True
    Label14.Visible = True
    CommandButton3.Caption = "MODIFICAR"
    CommandButton3.BackColor = &HFF&
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox2.Value = Format(TextBox2.Value, "##,###,###.000")
End Sub
Private Sub UserForm_Initialize()
' SE ADICIONA 
'----------------- 
Dim i, FF As Integer
Dim NF As Double
NF = Application.CountA(Sheets("Config").Range("A2:A50000")) + 2
'----------------- 
 
    Sheets("Config").Range("J2:q17").ClearContents
    ComboBox1.AddItem "1: 06.00/12.00"
    ComboBox1.AddItem "2: 12.00/18.00"
    ComboBox1.AddItem "3: 18.00/24.00"
    ComboBox1.AddItem "4: 24.00/06.00"
 
    ComboBox2.AddItem "1: WINCHERO"
    ComboBox2.AddItem "2: PORTALONERO"
    ComboBox2.AddItem "3: TARJADOR"
    ComboBox2.AddItem "4: BODEGUERO"
    ComboBox2.AddItem "5: MANIOBRISTA"
 
'----------------- 
    ComboBox3.RowSource = "Config!A2:A" & NF
'----------------- 
 
    ListBox1.ColumnCount = 8
    ListBox1.ColumnWidths = "40;160;50;50;60;70;30;30"
 
    Label8.Caption = Sheets("Config").Range("I1").Value
 
End Sub
Sub Restablecer_Valores()
 'restablecemos valores 
    ComboBox1.Value = ""
    ComboBox2.Value = ""
    ComboBox3.Value = ""
    CheckBox1.Value = False
    Label10.Caption = ""
 
    Label12.Caption = "CAPTURANDO"
    Label12.ForeColor = &H8000000D
    CommandButton3.BackColor = &H8000000D
    CommandButton3.Caption = "AGREGAR"
    Label14.Caption = ""
    Label13.Visible = False
    Label14.Visible = False
End Sub


Que en la imagen PANTALLA02.jpg, en la etiqueta DNI (ComboBox3 - digitamos 308222??) y mediante un textbox deberá mostrar los apellidos y nombres asociados en la etiqueta NOMBRE (label10.caption) y tras seleccionar el dato correcto, presionamos el botón “AGREGAR” nos traslado toda la información al ListoBox1.

Desde ya agradezco su apoyo y colaboración.