¿Cómo puedo crear la opción de abierto o cerrado en status?

Para dante amor

Como te lo comento, ahora quiero hacer lo mismo que de hizo en las notas pero para status, tiene que si o si decir ABIERTO o CERRADO.

En el caso que el usuario presione cerrado que se cancelen automáticamente las casillas de apelación y observación

1 respuesta

Respuesta

Te anexo todo el código, se cambió el textbox21 por combobox21

Dim h1, h2
'
Private Sub ComboBox21_Change()
    If ComboBox21 = "CERRADO" Then
        TextBox22 = ""
        TextBox23 = ""
    End If
End Sub
'
Private Sub CommandButton1_Click()
'Por.Dante Amor
    If IsNumeric(TextBox1) Then rut = Val(TextBox1) Else rut = TextBox1
    If ComboBox21.Value = "" Then
        MsgBox "Tiene que llenar el estatus", vbCritical
        ComboBox21.SetFocus
        Exit Sub
    End If
    Set b = h1.Columns("A").Find(rut, lookat:=xlWhole)
    If Not b Is Nothing Then
        fila = b.Row
        cargo = h1.Cells(fila, "C")
        Set c = h2.Columns("A").Find(cargo, lookat:=xlWhole)
        If Not c Is Nothing Then
            sum1 = (Val(ComboBox6) * h2.Cells(c.Row, "B") + _
                    Val(ComboBox7) * h2.Cells(c.Row, "C") + _
                    Val(ComboBox8) * h2.Cells(c.Row, "D") + _
                    Val(ComboBox9) * h2.Cells(c.Row, "E") + _
                    Val(ComboBox10) * h2.Cells(c.Row, "F") + _
                    Val(ComboBox11) * h2.Cells(c.Row, "G") + _
                    Val(ComboBox12) * h2.Cells(c.Row, "H")) * h2.Cells(c.Row, "I")
            sum2 = (Val(ComboBox13) * h2.Cells(c.Row, "J") + _
                    Val(ComboBox14) * h2.Cells(c.Row, "K") + _
                    Val(ComboBox15) * h2.Cells(c.Row, "L") + _
                    Val(ComboBox16) * h2.Cells(c.Row, "M") + _
                    Val(ComboBox17) * h2.Cells(c.Row, "N")) * h2.Cells(c.Row, "O")
            sum3 = (Val(ComboBox18) * h2.Cells(c.Row, "P") + _
                    Val(ComboBox19) * h2.Cells(c.Row, "Q")) * h2.Cells(c.Row, "R")
            resul = sum1 + sum2 + sum3
            h1.Cells(fila, "X") = Format(resul, "##0.00")
            Call Cargar(h1, fila)
            Call Limpiar
            TextBox1.SetFocus
            MsgBox "Datos actualizados"
        Else
            MsgBox "El cargo no existe en la hoja de ponderaciones"
        End If
    Else
        MsgBox "El Rut no existe"
    End If
End Sub
'
Sub Cargar(h1, fila)
    h1.Cells(fila, "A") = Val(TextBox1)
    h1.Cells(fila, "B") = TextBox2
    h1.Cells(fila, "C") = TextBox3
    h1.Cells(fila, "D") = TextBox4
    h1.Cells(fila, "E") = TextBox5
    h1.Cells(fila, "F") = Val(ComboBox6)
    h1.Cells(fila, "G") = Val(ComboBox7)
    h1.Cells(fila, "H") = Val(ComboBox8)
    h1.Cells(fila, "I") = Val(ComboBox9)
    h1.Cells(fila, "J") = Val(ComboBox10)
    h1.Cells(fila, "K") = Val(ComboBox11)
    h1.Cells(fila, "L") = Val(ComboBox12)
    h1.Cells(fila, "M") = Val(ComboBox13)
    h1.Cells(fila, "N") = Val(ComboBox14)
    h1.Cells(fila, "O") = Val(ComboBox15)
    h1.Cells(fila, "P") = Val(ComboBox16)
    h1.Cells(fila, "Q") = Val(ComboBox17)
    h1.Cells(fila, "R") = Val(ComboBox18)
    h1.Cells(fila, "S") = Val(ComboBox19)
    h1.Cells(fila, "T") = TextBox20
    h1.Cells(fila, "U") = ComboBox21
    If ComboBox21 = "CERRADO" Then
        TextBox22 = ""
        TextBox23 = ""
    End If
    h1.Cells(fila, "V") = TextBox22
    h1.Cells(fila, "W") = TextBox23
End Sub
Private Sub CommandButton2_Click()
'Buscar
    If TextBox1 = "" Then Exit Sub
    Set b = h1.Columns("A").Find(TextBox1, lookat:=xlWhole) 'Busca en la columna A
    If Not b Is Nothing Then                                'Si lo encuentra
        TextBox1 = h1.Cells(b.Row, "A").Value
        TextBox2 = h1.Cells(b.Row, "B").Value
        TextBox3 = h1.Cells(b.Row, "C").Value
        TextBox4 = h1.Cells(b.Row, "D").Value
        TextBox5 = h1.Cells(b.Row, "E").Value
        ComboBox6 = h1.Cells(b.Row, "F").Value
        ComboBox7 = h1.Cells(b.Row, "G").Value
        ComboBox8 = h1.Cells(b.Row, "H").Value
        ComboBox9 = h1.Cells(b.Row, "I").Value
        ComboBox10 = h1.Cells(b.Row, "J").Value
        ComboBox11 = h1.Cells(b.Row, "K").Value
        ComboBox12 = h1.Cells(b.Row, "L").Value
        ComboBox13 = h1.Cells(b.Row, "M").Value
        ComboBox14 = h1.Cells(b.Row, "N").Value
        ComboBox15 = h1.Cells(b.Row, "O").Value
        ComboBox16 = h1.Cells(b.Row, "P").Value
        ComboBox17 = h1.Cells(b.Row, "Q").Value
        ComboBox18 = h1.Cells(b.Row, "R").Value
        ComboBox19 = h1.Cells(b.Row, "S").Value
        TextBox20 = h1.Cells(b.Row, "T").Value
        Select Case h1.Cells(b.Row, "U").Value
            Case "ABIERTO", "CERRADO"
                ComboBox21 = h1.Cells(b.Row, "U").Value
        End Select
        TextBox22 = h1.Cells(b.Row, "V").Value
        TextBox23 = h1.Cells(b.Row, "W").Value
        TextBox24 = h1.Cells(b.Row, "X").Value
    Else
        MsgBox "El RUT no existe"                          'si no existe
    End If
End Sub
'
Private Sub TextBox1_Change()
    If TextBox1.Text = "" Then
        CommandButton1.Enabled = False
    Else
        CommandButton1.Enabled = True
    End If
End Sub
'
Private Sub UserForm_Activate()
'Act.Por.Dante Amor
    Set h1 = Sheets(1)
    Set h2 = Sheets("PONDERACIONES")
    TextBox24.Enabled = False
    If TextBox1.Text = "" Then
        CommandButton1.Enabled = False
    Else
        CommandButton1.Enabled = True
    End If
    For i = 6 To 19
        Me.Controls("ComboBox" & i).Style = 2
        Me.Controls("ComboBox" & i).AddItem ""
        For n = 1 To 5
            Me.Controls("ComboBox" & i).AddItem n
        Next
    Next
    ComboBox21.Style = 2
    ComboBox21.AddItem "ABIERTO"
    ComboBox21.AddItem "CERRADO"
End Sub
'
Sub Limpiar()
    TextBox1 = ""
    TextBox2 = ""
    TextBox3 = ""
    TextBox4 = ""
    TextBox5 = ""
    ComboBox6 = ""
    ComboBox7 = ""
    ComboBox8 = ""
    ComboBox9 = ""
    ComboBox10 = ""
    ComboBox11 = ""
    ComboBox12 = ""
    ComboBox13 = ""
    ComboBox14 = ""
    ComboBox15 = ""
    ComboBox16 = ""
    ComboBox17 = ""
    ComboBox18 = ""
    ComboBox19 = ""
    TextBox20 = ""
    ComboBox21 = ""
    TextBox22 = ""
    TextBox23 = ""
    TextBox24 = ""
End Sub
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas