Link to home
Start Free TrialLog in
Avatar of John Carney
John CarneyFlag for United States of America

asked on

How to prevent Excel from turning 1- 3 into a date

I have a file with a column that contains numbers with some dashes and spaces that display as text. I have a macro that takes an entry like 1-3 and converts it to 1,2,3. However if the cell contains a space before or after the dash, the macro converts it to  03-Jan. How do I trick Excel into reading "- " as a text hyphen and produce the result 1,2,3? I tried adding a line that removes the spaces but as soon as you do that the cell turns to 03-Jan.

Thanks!
John
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Format the column as Text.
SOLUTION
Avatar of Steven Carnahan
Steven Carnahan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John Carney

ASKER

Thanks!
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015, Experts-Exchange Top Expert Visual Basic Classic 2012 to 2014