How to remove special characters from numbers?

ivankesaulya

New Member
Joined
Feb 2, 2018
Messages
6
Dear all,

I have some difficulties trying to remove special characters from numbers section.

Here is the example;

13685421965|126
33512485|223654
4698875213615|1
99876252148631|

Help 1:
I need to count how many characters before that special character.

13685421965|126 ---> =LEN(*beforespecialcharacter*)

Help 2:
I need to erase that special character and the numbers written after that special character

13685421965|126 ---> 13685421965
33512485|223654 ---> 33512485
4698875213615|1 ---> 4698875213615
99876252148631| ---> 99876252148631

I can't thank you enough if anyone can help me with these problems :eeek::(


Warm regards,

Ivan Kesaulya
+6281318888266
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
In B2 enter:

=LEN(LEFT(A2,FIND("|",A2)-1))

In C2 enter:

=LEFT(A2,B2)

The foregoing set up assumes that | occurs once. Anyways it operates on the first occurrence of the | sign.
 
Upvote 0
Obviously, Aladin's suggestion (native excel) is the way to go but if it would be part of code, this might work.
Code:
Sub AAAAA()
Dim c As Range
For Each c In Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
    c.Offset(, 1).Value = Trim(Split(c, "|")(0))
Next c
End Sub
BTW, I would remove your phone number unless you want crank calls

Just saw you answer to Aladin. It is not part of code so just save it for possible future use!!!!!
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

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