I had a code working that would open a file type and delimit it appropriately where an = sign was used as the custom (Other) delimiter. When I tried it today, the files will be imported and saved, but not delimited at the = signs.
My entire code is shown at the bottom. I had not changed it yet now it does not work. I appreciate any input on this problem. The relevant code is:
Workbooks.OpenText filename:=folderPath & "" & filename, Origin:=437, StartRow:=1, _ DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, _ Tab:=True, Semicolon:=False, Comma:=True, Space:=False, Other:=True, OtherChar:="=", _ FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), TrailingMinusNumbers:=True
Sub DelimitingRecord()
'
' DelimitingRecord Macro
' Trying to re-do the "=" delimiting macro, yet still not working
'
Dim folderPath As String
Dim savefolderPath As String
Dim sourceWB As Workbook
Dim sourceWS As Worksheet
Dim lastRow As Long
Dim filename As String
' Specify the folder path where your source workbooks are located
folderPath = "U:Macro for Gloss-O-MetreQTX Raw"
' Specify the folder path where xlsx files are to be saved
savefolderPath = "U:Macro for Gloss-O-MetreXLSX from QTX"
' Check if the folder paths ends with a backslash, if not, add it
If Right(folderPath, 1) <> "" Then
folderPath = folderPath & ""
End If
If Right(savefolderPath, 1) <> "" Then
folderPath = folderPath & ""
End If
' Get the first file in the folder
filename = Dir(folderPath & "*.qtx")
' Loop through all files in the folder
Do While filename <> ""
' Open the workbook
Set sourceWB = Workbooks.Open(folderPath & "" & filename)
Workbooks.OpenText filename:=folderPath & "" & filename, Origin:=437, StartRow:=1, _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, _
Tab:=True, Semicolon:=False, Comma:=True, Space:=False, Other:=True, OtherChar:="=", _
FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), TrailingMinusNumbers:=True
sourceWB.SaveAs savefolderPath & "" & filename & ".xlsx", xlOpenXMLWorkbook
sourceWB.Close SaveChanges:=False ' Close the source workbook without saving
filename = Dir ' Move to the next file in the folder
Loop
End Sub
SconnorA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.