Text to Column not Working As Intended

TeckTeck

New Member
Joined
Sep 28, 2023
Messages
15
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi ive been trying to figure out why this text to column doesn't work, it seems like there is something to do with the formatting of "-". Although they look the same but i cant get them separated using Text to column. Please advice :(
image
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi,

If I were you, I would copy the problematic character, go to Find&Replace and replace all with a standard dash.
Not a real solution but maysolve this particular issue.
 
Upvote 0
Hi,

If I were you, I would copy the problematic character, go to Find&Replace and replace all with a standard dash.
Not a real solution but maysolve this particular issue.
Hi Flashbond, yes this would work however it would affect my vba code downstream. Hopefully i am able to have a vba code to replace the problematic dashes with a standard dash. Another thing that i noticed is that if i try to copy the excel cell value into a word document, the hypens disappears
 
Last edited:
Upvote 0
Ok,

First, find the asci code of that character for only once:
VBA Code:
Msgbox Asc(Mid(Cells(5, "M").Value, 4, 1))
Then write a macro replaces this ascii code with dashes like this:

VBA Code:
For i = 5 To 100
  vNewText = Cells(i, "M").Value
  Cells(i, "M").Value = WorksheetFunction.Substitute(vNewText, Chr(yourAsciiCode), "")
Next
 
Upvote 0
Solution
Ok,

First, find the asci code of that character for only once:
VBA Code:
Msgbox Asc(Mid(Cells(5, "M").Value, 4, 1))
Then write a macro replaces this ascii code with dashes like this:

VBA Code:
For i = 5 To 100
  vNewText = Cells(i, "M").Value
  Cells(i, "M").Value = WorksheetFunction.Substitute(vNewText, Chr(yourAsciiCode), "")
Next
This works perfectly, thank you Flashbond you're a savior :)
 
Upvote 0

Forum statistics

Threads
1,215,297
Messages
6,124,113
Members
449,142
Latest member
championbowler

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