Bom dia!
Consegui adaptar os codigos a minha planilha.
Agora preciso de mais uma ajuda que é muito fod4.
Podem me ajudar com um codigo que busque e abra varios arquivos em TXT nomeados com datas diferentes??
ex: 01/01/2014.txt
02/01/2014.txt e assim por diante
A estrutura de todos eles é a mesma
Abaixo segue o meu codigo que foi todo feito no modo mais basico. Gravar macro.
Workbooks.OpenText Filename:="J:2014Relatórios EOSAN064R1ANBP064C.txt", _
Origin:=xlMSDOS, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _
Array(0, 1), Array(12, 1), Array(21, 1), Array(53, 1), Array(61, 1), Array(71, 1), Array(87 _
, 1), Array(105, 1), Array(123, 1)), TrailingMinusNumbers:=True
Range("H1,H11,H21,H31,H41,H51,H61").Select
Range("H61").Activate
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.Replace What:="pa", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Sheets("ANBP064C").Select
Range("A7:H7,A17:H17,A27:H27,A37:H37,A47:H47,A57:H57,A67:H67").Select
Range("A67").Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Plan1").Select
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("ANBP064C").Select
Range("A2,A12,A22,A32,A42,A52,A62").Select
Range("A62").Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Plan1").Select
Range("J1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1:J6").Select
Application.CutCopyMode = False
Cells.Select
Application.CutCopyMode = False
With Selection.Font
.Name = "Calibri"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
Range("A1:J6").Select
Selection.Copy
Windows("Seleção x Ctas à Pagar_2014 - Cópia.xlsm").Activate
Range("A3").Select
Selection.Insert Shift:=xlDown
Columns("A:A").Select
Application.CutCopyMode = False
Selection.NumberFormat = "dd/mm/yyyy"
Columns("H:H").Select
Selection.NumberFormat = "dd/mm/yyyy"
Range("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range("A3:J160").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("P1").Select
ActiveWorkbook.Worksheets("ARV").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ARV").AutoFilter.Sort.SortFields.Add Key:=Range( _
"A1:A861"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("ARV").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("P1").Select
Range("N1").Select
Windows("ANBP064C.txt").Activate
ActiveWindow.Close False
Range("P1").Select
ActiveWorkbook.Worksheets("ARV").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ARV").AutoFilter.Sort.SortFields.Add Key:=Range( _
"A1:A735"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("ARV").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("I:I").Select
Selection.NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* ""-""??_);_(@_)"
Range("P1").Select
End Sub
Postado : 29/01/2014 7:49 am