I want to change format from Date to Number and It doesnt changes. I have to click two times on every cell to change it.
I found a solution that text to column works here. Unfortunatelly the recorded code doesn't work.
Worksheets("Data for LN").Range("i2:i" & datarange).Select
Selection.NumberFormat = "0.00"
Selection.TextToColumns Destination:=Range("I2"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Any ideas how to change it?
Related
ActiveCell.EntireColumn.Select
Selection.TextToColumns Destination:=Range("G1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 4), TrailingMinusNumbers:=True
Selection.NumberFormat = "dd-mmm-yy"
I found the solution , Thanks for support , Modified code should be
ActiveCell.EntireColumn.Select
Dim myRange As Range
Set myRange = Selection
myRange.TextToColumns Destination:=myRange, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 4), TrailingMinusNumbers:=True
Selection.NumberFormat = "dd-mmm-yy"
I have recorded a macro that will convert a column of dates in UK format to text by using Text to Columns when recording it, but the text it returns is in US format. Text to Columns does the job when its outside of a macro so not sure why it wouldn't work when used in a macro.
Is there a way to have the text in UK format and not have it converted to US format? I believe the below is the relevant part:
Selection.TextToColumns Destination:=Range("E1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 2), TrailingMinusNumbers:=True
Columns("F:F").Select
Selection.TextToColumns Destination:=Range("F1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 2), TrailingMinusNumbers:=True
Columns("A:P").Select
Selection.Copy
Windows("Xero Upload Template V2.xlsx").Activate
Range("A4").Select
ActiveSheet.Paste```
If I understand correctly then your data is in column 5 and 6 which you need to convert. Please try below code.
Dim c As Long
For c = 5 To 6
Columns(c).TextToColumns DataType:=xlDelimited, Tab:=False, Semicolon:=False,
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 5)
Columns(c).NumberFormat = "dd-mm-yyyy"
Next c
I am currently making a report based off of Stats in my company. The raw data that I receive has date with a Time Stamp (2 Date Columns - Created/Received). To Remove the time stamp, I set the a custom format to m/d/yyyy and then Delimit each column separately which gives me the correct date. Once I assign my Macro to a button and add new Raw Data I receive this error ----
Does anyone have any tips or understand why I am getting this error even though I am only Delimiting one column at a time?
Sub ComplianceOTRSMacro()
' ComplianceOTRSMacro Macro
' Format Date - Refresh Pivot Tables
Columns("D:E").Select
Selection.NumberFormat = "m/d/yyyy"
Columns("D:D").Select
Selection.TextToColumns Destination:=Range("OTRSData[[#Headers],[Created]]") _
, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
TrailingMinusNumbers:=True
Columns("E:E").Select
Selection.TextToColumns Destination:=Range( _
"OTRSData[[#Headers],[Close Time]]"), DataType:=xlDelimited, TextQualifier _
:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:= _
False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1) _
, TrailingMinusNumbers:=True
Range("OTRSData[[#Headers],[Ticket'#]]").Select
Sheets("Dashboard").Select
ActiveWorkbook.RefreshAll
End Sub
I am facing issue after copy and paste from export file from SAP it ask to convert to number option which is like error without converting to number formulas do not work. also cell value is number only.
I tried to make macro but it works on single column only. how to make it work on multiple column together and make it faster also as it stuck exel for long time.
code for converting to number
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Columns("F:F").Select
Selection.TextToColumns Destination:=Range("F1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Columns("G:G").Select
Selection.TextToColumns Destination:=Range("G1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
How shorter code and combine for multiple columns in single line.
Use an xlFixedWidth in your Range.TextToColumns method.
Dim c As Long, vCOLs As Variant
vCOLs = Array(1, 6, 7) 'columns A, F and G
With Worksheets("Sheet1")
For c = LBound(vCOLs) To UBound(vCOLs)
With .Column(c)
.TextToColumns Destination:=.Cells(1), DataType:=xlFixedWidth, _
FieldInfo:=Array(0, 1), TrailingMinusNumbers:=True
End With
Next c
End With
The variant array allow you to quickly specify the columns to be processed. Even with a large (~250K) number of rows, this should be fairly quick to cycle through.
I need some help getting my script to work with AHK_L COM Excel on TextToColumns. I've looked around but can't seem to locate enough examples to get me going. When I have run my VBA macro this is what I end up with:
Selection.TextToColumns Destination:=Range("D1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=":", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), _
TrailingMinusNumbers:=True
Examples I have found look like my code should be:
xl.Selection.TextToColumns([color=#FF0000]xl.range("D1")[/color],1,1,0,1,0,0,0,1,":")
But nothing happens to my column that's selected.
Any ideas? Thanks in advance for your time.
xl.Selection.TextToColumns(xl.range("D1"),1,1,0,1,0,0,0,1,":")
Try it with out the color tags