Como adicionar macros en archivos con barra de progreso previo

Para Dante Amor

Solicito tu colaboración .. Como se puede adicionar una nueva macro en una que tiene una barra de progreso para que la incluya en el avance de la barra...

Respuesta
1

H o l a:

Te anexo la macro actualizada:

Sub principal()
'Por.Dante Amor
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    '
    DoEvents
    ruta = "D:\REPORTES\"
    ruta = ThisWorkbook.Path & "\"
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;" & ruta & "desbloqueos Noviembre.txt", _
        Destination:=Range("$A$1"))
        .Name = "desbloqueos Noviembre"
        .FieldNames = True: .RowNumbers = False: .FillAdjacentFormulas = False
        .PreserveFormatting = True: .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells: .SavePassword = False
        .SaveData = True: .AdjustColumnWidth = True: .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False: .TextFilePlatform = 65001
        .TextFileStartRow = 1: .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False: .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False: .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False: .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
        .TextFileTrailingMinusNumbers = True: .Refresh BackgroundQuery:=False
    End With
    '
    DoEvents
    Label1 = "Procesando Datos ..."
    con = 1
    rep = 10
    '
    fin = Range("A" & Rows.Count).End(xlUp).Row
    For i = fin To 1 Step -1
        If WorksheetFunction.CountA(Rows(i)) = 0 Then
            Rows(i).Delete
        ElseIf Cells(i, "A") Like "*0x*" Or _
           Cells(i, "A") Like "*The*" Or _
           Cells(i, "A") Like "*If*" Or _
           Cells(i, "A") Like "*S-1*" Then
            Rows(i).Delete
        ElseIf Cells(i, "A") Like "*$*" Then
            Rows(i + 1).Delete
            Rows(i).Delete
            Rows(i - 1).Delete
            i = i - 1
        ElseIf Cells(i, "A") <> "sosservicios" And Left(Cells(i, "A"), 3) = "SOS" Then
            Rows(i).Delete
        End If
        '
        If (con * 100) / fin >= rep Then
            UpdateProgressBar rep
            rep = rep + 10
        End If
        con = con + 1
    Next
    UpdateProgressBar rep
    Application.ScreenUpdating = True
    Label1 = "Proceso Terminado"
End Sub

Lo que hice, fue agregar un elseif, para preguntar si la línea tiene el símbolo $

ElseIf Cells(i, "A") Like "*$*" Then
Rows(i + 1).Delete
Rows(i).Delete
Rows(i - 1).Delete
I = i - 1 

Entonces, si la línea tiene el símbolo & borra la línea posterior, la línea y la línea anterior; como la línea anterior fue borrada, el contador de líneas lo tengo que disminuir, para que ya no evalúe la línea que fue borrada y se pase a la siguiente.


Añade tu respuesta

Haz clic para o

Más respuestas relacionadas