Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I have a cell with a sentence in text and numbers in between. Is there a formular so that if I write the formular in B1, it will give me all the numbers or give me only the text og A1 ? Thanks -- Therese |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here are a couple of User Defined Functions you can use.
Public Function PullText(rngTemp As Range) Dim strTemp As String For i = 1 To Len(rngTemp.Value) If (Asc(Mid(rngTemp.Value, i, 1)) <= 47 Or Asc(Mid(rngTemp.Value, i, 1)) = 58) Then strTemp = strTemp & Mid(rngTemp.Value, i, 1) End If Next i PullText = strTemp End Function Public Function PullNumbers(rngTemp As Range) Dim strTemp As String For i = 1 To Len(rngTemp.Value) If (Asc(Mid(rngTemp.Value, i, 1)) = 48 And Asc(Mid(rngTemp.Value, i, 1)) <= 57) Then strTemp = strTemp & Mid(rngTemp.Value, i, 1) End If Next i PullNumbers = strTemp End Function |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hHi Kletcko
Thanks a lot for you help, I will see if I can use it, and ten efter that I will go back to "general questions" where I belong. A bit too tough for me, but thanks for your time. -- Therese "Kletcho" skrev: Here are a couple of User Defined Functions you can use. Public Function PullText(rngTemp As Range) Dim strTemp As String For i = 1 To Len(rngTemp.Value) If (Asc(Mid(rngTemp.Value, i, 1)) <= 47 Or Asc(Mid(rngTemp.Value, i, 1)) = 58) Then strTemp = strTemp & Mid(rngTemp.Value, i, 1) End If Next i PullText = strTemp End Function Public Function PullNumbers(rngTemp As Range) Dim strTemp As String For i = 1 To Len(rngTemp.Value) If (Asc(Mid(rngTemp.Value, i, 1)) = 48 And Asc(Mid(rngTemp.Value, i, 1)) <= 57) Then strTemp = strTemp & Mid(rngTemp.Value, i, 1) End If Next i PullNumbers = strTemp End Function |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You would copy these into a module in your workbook (alt-F11 to get to
the visual basic editor and then Insert - Module to get a module. Paste the code in the white area.) Then in a cell in your workbook you would refer to the formula like any other default excel formula: =PullNumbers(A1) or =PullText(A1) |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Tue, 18 Apr 2006 09:24:02 -0700, Therese
wrote: Hi I have a cell with a sentence in text and numbers in between. Is there a formular so that if I write the formular in B1, it will give me all the numbers or give me only the text og A1 ? Thanks Another option would be to download and install Longre's free morefunc.xll add-in from http://xcell05.free.fr/. This can be distributed freely with your workbook. You can then use the regular expression formulas: =REGEX.SUBSTITUTE(A1,"\D") to extract the numbers and =REGEX.SUBSTITUTE(A1,"\d") to extract everything that is not a number. This will work unless your sentence has more than 255 characters. If it does, similar solutions using VBA regular expressions can be devised. --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
HOW DO I EXTRACT NUMBERS FROM TEXT STRING | Excel Discussion (Misc queries) | |||
how to extract numbers from imported cell with text and numbers? | Excel Discussion (Misc queries) | |||
Extract numbers from cell with Text and Numbers | New Users to Excel | |||
How do I extract numbers from a cell with both text and numbers? | Excel Worksheet Functions | |||
extract numbers from cell containing text & numbers | Excel Worksheet Functions |