Multiple file - Data legacy wizard macro

mholme58

New Member
Joined
Jul 27, 2010
Messages
44
I currently have a process where I have multiple files in a folder that need to be converted in legacy wizard to the correct format for upload.
The macro for this is a bit above my skill level, so could do with some help. I've pasted the below, which I know doesn't work, but gives you an idea of what I need to do (hopefully)

The steps at the start I need are -
Open new workbook
Data > Get Data > Legacy Wizard > From Text (Legacy)
Select file from Y:\3.BARCLAYS BACS TFR REPORT (there are multiple files that will need converting, and each needs to be converted - between 5 to 20 files)
Delimited > Next > untick Tab and tick Comma > Convert columns 1, 2 & 3 to text > Finish
Column D to 2 decimal places
Repeat for next file in the folder

As I said, the below doesn't work, it bugs out at .CommandType = 0, but I just pasted this for reference as to what I am trying to do.

Sub Convert_BACs_Files()
'
' Convert_BACs_Files Macro
' Macro to convert all files to correct format
'

'
Application.CutCopyMode = False
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;Y:\3.BARCLAYS BACS TFR REPORT\JTCL WK44.csv", Destination:=Range("$A$1" _
)) *Won't always be this file name - needs to open every file in this folder
.CommandType = 0 *Bugs out here
.Name = "JTCL WK44"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2, 2, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Columns("D:D").Select
Selection.NumberFormat = "0.00"
Range("A1").Select
End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top