S
Sinner
Hi,
I'm using below macro to load a text file in excel. The text file has
30 columns where as after running the macro, only 26 columns are
loaded.
-------------------------------------------------------------------
Private Sub CommandButton1_Click()
On Error Resume Next
Dim sFile
Application.ScreenUpdating = False
Application.DisplayAlerts = False
sFile = Application.GetOpenFilename( _
FileFilter:="Text Files (*.txt), *.txt", FilterIndex:=1, _
Title:="Import File")
If sFile <> False Then
Workbooks.OpenText Filename:=sFile, Origin:=437, _
StartRow:=9, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Other:=True, OtherChar:="|",
FieldInfo:=Array(Array(1, 2 _
), Array(2, 1), Array(3, 2), Array(4, 1), Array(5, 1),
Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 2), Array(12, 1),
Array(13, 1), Array(14, 1), Array(15, 1), _
Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1),
Array(20, 1), Array(21, 1), Array(22, 1), _
Array(23, 1), Array(24, 2), Array(25, 1), Array(26, 2),
Array(27, 2), Array(28, 1), Array(29, 2), Array(30, 1)), _
TrailingMinusNumbers:=True
ActiveSheet.UsedRange.Select
Selection.Copy
ActiveWorkbook.Close
Worksheets("User").Activate
Range("A1:Z65536").Select
ActiveSheet.Paste
Range("A1").Select
ActiveWindow.Zoom = 85
Cells.EntireColumn.AutoFit
Cells.EntireRow.AutoFit
End If
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
I'm using below macro to load a text file in excel. The text file has
30 columns where as after running the macro, only 26 columns are
loaded.
-------------------------------------------------------------------
Private Sub CommandButton1_Click()
On Error Resume Next
Dim sFile
Application.ScreenUpdating = False
Application.DisplayAlerts = False
sFile = Application.GetOpenFilename( _
FileFilter:="Text Files (*.txt), *.txt", FilterIndex:=1, _
Title:="Import File")
If sFile <> False Then
Workbooks.OpenText Filename:=sFile, Origin:=437, _
StartRow:=9, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Other:=True, OtherChar:="|",
FieldInfo:=Array(Array(1, 2 _
), Array(2, 1), Array(3, 2), Array(4, 1), Array(5, 1),
Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 2), Array(12, 1),
Array(13, 1), Array(14, 1), Array(15, 1), _
Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1),
Array(20, 1), Array(21, 1), Array(22, 1), _
Array(23, 1), Array(24, 2), Array(25, 1), Array(26, 2),
Array(27, 2), Array(28, 1), Array(29, 2), Array(30, 1)), _
TrailingMinusNumbers:=True
ActiveSheet.UsedRange.Select
Selection.Copy
ActiveWorkbook.Close
Worksheets("User").Activate
Range("A1:Z65536").Select
ActiveSheet.Paste
Range("A1").Select
ActiveWindow.Zoom = 85
Cells.EntireColumn.AutoFit
Cells.EntireRow.AutoFit
End If
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub