Excel - CAMBIO DE COMBOBOX POR TEXTBOX

 
Vista:
Imágen de perfil de JOSE LUIS
Val: 80
Ha disminuido su posición en 3 puestos en Excel (en relación al último mes)
Gráfica de Excel

CAMBIO DE COMBOBOX POR TEXTBOX

Publicado por JOSE LUIS (60 intervenciones) el 03/07/2019 00:23:07
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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
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.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder