Text to Column in VBA not working

JoeC1

New Member
Joined
Jul 11, 2013
Messages
6
Hi,

I am trying to use Text to column in VBA but when i run through a macro it doesn't seem to perform the function. I am using this so dates are in the right format for conditional formatting in other cells. below is some code. the amount of rows in the column can vary so i have used

Range(Selection, Selection.End(xlDown)).Select .....as per below. any help appreciated. even when i record this i get the same thing and it works when not run through the macro.



Range("X25").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.TextToColumns Destination:=Range("X25"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hello there,
I am not sure of getting what you intend to do.
Are you trying to split the content of Range("X25") into two parts as First and last name?
 
Upvote 0
Hi,

hmm no. basically i have conditional formatting in some sells that look to see if 2 dates are the same. as these dates are pulled in from 2 separate files the format of the dates are different ( i believe one is set as text and one isnt). when i click the Text to column button (not in a macro) this seem to rectify my conditional formatting issue and the conditional formatting then registers that the 2 dates are the same. does this make sense?
 
Upvote 0
i forgot to say that i am doing this over a a number of rows in 1 column and when i manually click Text to column i click finish straight after. this then just seems to convert the dates and replace them back into their original cell but in the correct format for my conditional formatting. thanks
 
Upvote 0
For text format cells, you may use a formula called: DATEVALUE it actually converts dates stored as text into absolute date values.
After using this formula you will be able to perform your date comparisons as you wish.
I think that would be it.
Regards.
 
Upvote 0
I tried this before but as some of the dates seem to have already had text to column applied (from source files)/ the format is different when i use DATEVALUE for some dates it just returns #VALUE!. As these formats seem to be inconstant the only thing i have found that works is the Text to col button, but not in my macro.

Thanks
 
Upvote 0
Try to perform a concatenation to those columns then apply the formula on the resulted values.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top