Necesito validar que existan 8 libros cada uno tiene nombre diferente y que cada uno de estos contenga una hoja llamada Vigentes

Que tal necesito validar la existencia de 8 libros Excel y cada uno de ellos tiene una hoja llamada Vigentes ¿Cómo puedo hacer la validación con una macro?

1 Respuesta

Respuesta
1

H o l a Laura:

Preparo la macro y te la envío.

Sal u dos

H o l a:

Te anexo la macro para validar los 8 libros.

Sub ProcesarInformacion()
'Por.Dante Amor
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Application.StatusBar = False
    Set l1 = ThisWorkbook
    Set h1 = l1.Sheets(1)
    ruta = l1.Path & "\"
    u = h1.Range("A" & Rows.Count).End(xlUp).Row
    If u < 3 Then u = 3
    h1.Range("C3:AJ" & u).ClearContents
    '
    For i = 3 To u
        msj1 = ""
        arch = h1.Cells(i, "A") & ".xlsx"
        Application.StatusBar = "Leyendo archivo: " & arch & ". Actualizando estado: "
        If Dir(ruta & arch) = "" Then
            msj1 = "No existe archivo"
        Else
            Set l2 = Workbooks.Open(ruta & arch, , True)
            existe = False
            For Each h In Sheets
                If UCase(h.Name) = "VIGENTES" Then
                    existe = True
                    Exit For
                End If
            Next
            If existe = False Then
                msj1 = "No existe hoja Vigentes"
            Else
                msj1 = "Procesando"
            End If
            l2.Close
            Set l2 = Nothing
        End If
        'Actualizar estatus
        h1.Cells(i, "C") = Now
        h1.Cells(i, "D") = msj1
    Next
    Application.StatusBar = False
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    MsgBox "Fin"
End Sub

':)
'S aludos. D a n t e   A m o r . R ecuerda valorar la respuesta. G racias
':)

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas