ITALIAORIANA
Technical User
Hi,
I have been searching for quite a while trying to figure this out. I have a simple comma delimited formatting macro I recorded in excel to format an exported file from a program called Redgate.
This file is exported in .csv format. After using the macro I noticed the data in certain columns lost the leading zero which is variable based on a 3 character field.
I am not familiar with arrays and have been trying to find information explaining how they work based on what it looks like in the macro below.
After playing around with it, I changed all the ",1" to ",2" (Array(Array(1, 1) to Array(Array(1, 2), Array(Array(2, 1) to Array(Array(2, 2) and so forth.)
This actually worked and now the leading zero's are showing. But I need to understand why this worked.
It's difficult to google this when I have no idea how to ask for what I need. If anyone can point me in a direction where I can find information to explain why this worked THAT would be fantastic.
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo:= _
Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7 _
, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), 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, 1), Array(25, 1), Array(26, 1), Array( _
27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1), _
Array(34, 1), Array(35, 1)), TrailingMinusNumbers:=True
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
Cells.Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.NumberFormat = "@"
End With
Range("A2").Select
ActiveWindow.FreezePanes = True
End Sub
Thanks
Deana
I have been searching for quite a while trying to figure this out. I have a simple comma delimited formatting macro I recorded in excel to format an exported file from a program called Redgate.
This file is exported in .csv format. After using the macro I noticed the data in certain columns lost the leading zero which is variable based on a 3 character field.
I am not familiar with arrays and have been trying to find information explaining how they work based on what it looks like in the macro below.
After playing around with it, I changed all the ",1" to ",2" (Array(Array(1, 1) to Array(Array(1, 2), Array(Array(2, 1) to Array(Array(2, 2) and so forth.)
This actually worked and now the leading zero's are showing. But I need to understand why this worked.
It's difficult to google this when I have no idea how to ask for what I need. If anyone can point me in a direction where I can find information to explain why this worked THAT would be fantastic.
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo:= _
Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7 _
, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), 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, 1), Array(25, 1), Array(26, 1), Array( _
27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1), _
Array(34, 1), Array(35, 1)), TrailingMinusNumbers:=True
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
Cells.Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.NumberFormat = "@"
End With
Range("A2").Select
ActiveWindow.FreezePanes = True
End Sub
Thanks
Deana