Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Extracting numbers from a text

How can i extract just the numbers from a text cell??

Example: Turn this: 000 234 -1 k -- into this: 2341
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,393
Default Extracting numbers from a text

Give us a few more examples of what you input can look like so we can better
advise
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"AshMorK" wrote in message
...
How can i extract just the numbers from a text cell??

Example: Turn this: 000 234 -1 k -- into this: 2341



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Extracting numbers from a text

You could employ a user defined function.

Function DeleteNonNumerics(ByVal sStr As String) As Long
Dim i As Long
If sStr Like "*[0-9]*" Then
For i = 1 To Len(sStr)
If Mid(sStr, i, 1) Like "[0-9]" Then
DeleteNonNumerics = DeleteNonNumerics & Mid(sStr, i, 1)
End If
Next i
Else
DeleteNonNumerics = sStr
End If
End Function

usage is: =deletenonnumerics(cellref)

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the above code in there. Save the
workbook and hit ALT + Q to return to Excel window.

Enter the formula in any cell as shown above.


Gord Dibben Excel MVP

On Wed, 15 Nov 2006 12:27:02 -0800, AshMorK
wrote:

How can i extract just the numbers from a text cell??

Example: Turn this: 000 234 -1 k -- into this: 2341


Gord Dibben MS Excel MVP
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy from a Cell to a text box. AJL Excel Worksheet Functions 9 November 7th 06 04:58 PM
Sum multiple cells with different numbers and text. chrisjwhite24 Excel Discussion (Misc queries) 1 June 30th 06 05:03 PM
How can I use "VLOOKUP" with cells containing both Text & Numbers? Brentp97 Excel Worksheet Functions 7 February 24th 06 09:24 PM
Numbers stored as text causes problem with VLOOKUP bpeltzer Excel Worksheet Functions 0 February 4th 06 08:07 PM
How to convert Excel imported numbers from text to numbers? Alden Excel Discussion (Misc queries) 9 April 1st 05 09:51 PM


All times are GMT +1. The time now is 12:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"