Como generar vista previa de recibos de sueldos al tener varios sectores en la empresa con VBA

Buenas noches Experto Dante!! Como estás? Una consulta, hay alguna forma de generar vista previa de mis recibos de sueldos en pantalla por sector, ejemplo tengo una planilla en excel cuyos empleados se subdividen por sectores (administracion, ventas, producción, compras) lo que quiero hacer es que atraves de un botón de comando me genere vista previa por sector de los recibos de los empleados, si me podrías ayudar con alguna macro te lo voy a agradecer muchas gracias

1 Respuesta

Respuesta
1

Esta es la parte del código para la vista previa.

Private Sub CommandButton1_Click()
'Por.Dante Amor
    consultar "recibo" 'vista previa
    'CommandButton5.SetFocus
End Sub
Sub consultar(opcion)
'Por.Dante Amor
    Application.ScreenUpdating = False
    If ComboBox2 = "" Then
        MsgBox "Ingresa el aÑO", vbExclamation, "Trebolsoft System"
        ComboBox2.SetFocus
        Exit Sub
    End If
    If ComboBox1 = "" Then
        MsgBox "Ingresa el Mes", vbExclamation, "Trebolsoft System"
        ComboBox1.SetFocus
        Exit Sub
    End If
    If TextBox1 = "" Then
        MsgBox "Ingresa el código", vbExclamation, "Trebolsoft System"
        TextBox1.SetFocus
        Exit Sub
    End If
    If valida_archivo() Then
        Set b = h2.Columns("B").Find(Val(TextBox1), LookAt:=xlWhole)
        If Not b Is Nothing Then
            TextBox3 = h2.Cells(b.Row, "C")
            TextBox4 = h2.Cells(b.Row, "A")
            Select Case UCase(h2.Cells(b.Row, "A"))
                Case "ADMINISTRACION": Set h1 = l1.Sheets("ADMINISTRACION")
                Case "VENTAS": Set h1 = l1.Sheets("VENTAS")
                Case "PRODUCCION": Set h1 = l1.Sheets("PRODUCCION")
            End Select
            h1.[G13] = h2.Cells(b.Row, "C")
            h1.[C13] = h2.Cells(b.Row, "R")
            h1.[E7] = CONVERTIRNUM(h2.Cells(b.Row, "R"), False)
            Select Case opcion
            Case "nombre"
            Case "recibo"
                UserForm2.Hide
                h1.PrintPreview
                h3.Activate
                UserForm2.Show
            Case "pdf"
                ruta = l1.Path
                arch = h2.Cells(b.Row, "C") & "-" & ComboBox1 & "-" & ComboBox2
                h1.ExportAsFixedFormat Type:=xlTypePDF, _
                    Filename:=ruta & "\" & arch & ".pdf", _
                    Quality:=xlQualityStandard, IncludeDocProperties:=True, _
                    IgnorePrintAreas:=False, OpenAfterPublish:=False
                h3.Activate
            End Select
        Else
            MsgBox "El Código no existe", vbCritical, "Trebolsoft System"
            TextBox1.SetFocus
        End If
        l2.Close False
    Else
        MsgBox "El archivo no existe", vbCritical, "Trebolsoft System"
        ComboBox1.SetFocus
    End If
    CommandButton1.SetFocus
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas