Experimente o cadogo
Sub Importa()
Dim lLinha As Long, sPasta As String, lX As Long
'por Reinaldo
Application.ScreenUpdating = False
'Alterar caminho para o arquivo txt
Workbooks.OpenText Filename:="D:ReinaldoDropboxMATR450.TXT", Origin:= _
xlMSDOS, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1) _
, Array(14, 9), Array(16, 1), Array(47, 2), Array(50, 9), Array(56, 1), Array(67, 1), Array( _
82, 1), Array(100, 9), Array(106, 1), Array(118, 1), Array(133, 1), Array(151, 9), Array( _
156, 1), Array(168, 1), Array(182, 9), Array(213, 1), Array(219, 9)), _
TrailingMinusNumbers:=True
Workbooks("MATR450.TXT").Activate
lLinha = Workbooks("MATR450.TXT").Worksheets(1).Cells(Cells.Rows.Count, "A").End(xlUp).Row
For lX = lLinha To 1 Step -1
If Left(Cells(lX, 1), 1) = "*" Or Left(Cells(lX, 1), 1) = "-" Or Left(Cells(lX, 1), 1) = "" Or Cells(lX, 1) Like "Total*" Then
Cells(lX, 1).EntireRow.Delete
End If
Next
Rows("1:2").EntireRow.Delete
Cells.Select
Cells.EntireColumn.AutoFit
Selection.Copy Destination:=Workbooks("Modelo.xls").Worksheets("Plan1").Range("A1")
Range("A1").Select
Workbooks("MATR450.TXT").Close Saved = False
Application.ScreenUpdating = True
End Sub
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 28/03/2014 9:16 am