ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   remove text from cell (https://www.excelbanter.com/excel-discussion-misc-queries/101164-remove-text-cell.html)

Sam

remove text from cell
 
I need to remove text from cell and show only numbers
example number 510-889.

Each cell contains different amount of text.

Thanks!!


Alan

remove text from cell
 
Can you provide more information Sam? Whilst the string length varies
do the numbers always come at the front or the end or do they appear
somwhere in the middle?

Is the format of the numbers always the same 123-456?

Do the numbers appear as a single substring or are they spread
throughout your text?

Sam wrote:
I need to remove text from cell and show only numbers
example number 510-889.

Each cell contains different amount of text.

Thanks!!



Marcelo

remove text from cell
 
hi,

copy this module (ALT+F11) and use a function =digitsonly(a2)

hth
regards from Brazil
Marcelo

************************************************** *
Public Function DigitsOnly(sStr As String) As Variant
Dim oRegExp As Object

Set oRegExp = CreateObject("VBScript.RegExp")

With oRegExp
.IgnoreCase = True
.Global = True
oRegExp.Pattern = "\D"

DigitsOnly = oRegExp.Replace(sStr, vbNullString)
End With
End Function
************************************************



"Sam" escreveu:

I need to remove text from cell and show only numbers
example number 510-889.

Each cell contains different amount of text.

Thanks!!



All times are GMT +1. The time now is 04:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com