como importar arquivo OFX com VBA excell
Sub Importar()
Dim Cam As String
Dim ARQ As FileDialog
Set ARQ = Application.FileDialog(msoFileDialogFilePicker)
With ARQ
.Title = "localizar aquivo ofx"
.InitialFileName = Sheets(2).Range("a1")
.Filters.Add "Arquivo ofx", "*.ofx"
.Show
Cam = .SelectedItems(1)
End With
Dim Ln As Variant
Ln = 1
Open Cam For Input As #1
Do Until EOF(1)
Line Input #1, Linha
Cells(Ln, 1).Value = Linha
Ln = Ln + 1
Loop
Close #1
Range("a:a").TextToColumns , , , , , , , , other:=True, otherchar:=">"
Range("b1").EntireColumn.TextToColumns , , , , , , , , other:=True, otherchar:="<"
Dim Cl As Variant
Dim Grv As Variant
Dim Col As Variant
Cl = 30
Grv = 3
Col = 5
Range("d" & Grv - 1).Value = "DATA"
Range("f" & Grv - 1).Value = "HISTÓRICO"
Range("g" & Grv - 1).Value = "VALOR"
Do
If Range("a" & Cl).Value = "" Then
Range("a1").EntireRow.Delete
Call Organizar
Exit Sub
End If
Cells(Grv, Col + 3).Value = Left(Range("b" & Cl).Value, 1)
Cells(Grv, Col).Value = Range("b" & Cl + 1).Value
Cells(Grv, Col + 2).Value = Range("b" & Cl + 2).Value
Cells(Grv, Col + 1).Value = Range("b" & Cl + 5).Value
Cl = Cl + 8
Grv = Grv + 1
Loop
End Sub
Nenhum comentário:
Postar um comentário