When a report is exported from our system, dates are shown as 'yyyy / month name'.
I tried changing them to date format by creating a custom one on Excel > Home tab. Only when I click on one column and convert it to text, will it change to date format, from general "2015 March" to date 2015/03/01.
I am now trying to run a macro to convert all columns that contains these month/year dates to text, as I found no way else to fix the 1004 message.
Sub Text_to_columns()
'
' Text_to_columns Macro
'
'
Range("H2").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Replace What:=" / ", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Dim col As Range
Dim i As Integer
For i = 8 To 300
Selection.TextToColumns Destination:=Cells(2, i), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 5), TrailingMinusNumbers:=True
Next i
End Sub
It shows
1004 error
Microsoft can only convert one column at a time
How can I fix this? Is there another method to convert those text to dates?
Sub showNumberFormat(): MsgBox Range("H2").NumberFormat: End Sub
. Just copy/paste and run. – VBasic2008