Excel extraiga informacion de notepads y los elimine
Tengo un código que me permite extraer información de notepads mediante una macro colocándolos en la misma carpeta donde esta el excel, pero necesito que después de extraer la información los elimine, y no se si se pueda hacer eso.
Sub LeerNotePad2()
'Por.Dante Amor
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set l1 = ThisWorkbook
Set h1 = l1.ActiveSheet
ruta = l1.Path & "\"
arch = Dir(ruta & "*.txt")
'
lets = Array("A", "B")
cols = Array("C", "H")
fils = Array(9, 9)
Do While arch <> ""
letra = Mid(arch, Len(arch) - 4, 1)
arr = ""
For i = LBound(lets) To UBound(lets)
If letra = lets(i) Then
arr = i
Exit For
End If
Next
If arr <> "" Then
col = Columns(cols(arr)).Column
fil = fils(arr)
Set l2 = Workbooks.Open(ruta & arch)
Set h2 = l2.Sheets(1)
Set r = h2.Columns("A")
Set b = r.Find("Ch.", lookat:=xlPart)
If Not b Is Nothing Then
ncell = b.Address
Do
dato1 = Split(h2.Cells(b.Row + 1, "A"), ",")
dato2 = Split(h2.Cells(b.Row + 2, "A"), ",")
h1.Cells(fil, col + 1) = dato1(1)
h1.Cells(fil, col + 2) = dato1(3)
h1.Cells(fil, col + 3) = dato2(1)
h1.Cells(fil, col + 4) = dato2(3)
fil = fil + 1
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> ncell
End If
l2.Close
End If
arch = Dir()
Loop
Application.ScreenUpdating = True
MsgBox "Proceso terminado", vbInformation, "LEER ARCHIVOS"
End Sub
1 respuesta
Respuesta de Elsa Matilde
1