Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default remove non-numeric characters from cells

I have a column with data that may contain both text and numbers. Is there a
macro that extracts only the numbers and place them in the adjacent column?
Example:
Column A Column B
Row 1 A12 12
Row 2 BB121 121
Row 3 1E 1
Row 4 13AA 13
Row 5 66 66

Your help is much appreciated! Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default remove non-numeric characters from cells

I don't know if there's a built-in function but you can do it yourself like:

Public Function Digits(sVal As String)
'
Dim Digit As String
Dim i As Long
'
For i = 1 To Len(sVal)
Digit = Mid(sVal, i, 1)
If Digit = "0" And Digit <= "9" Then Digits = Digits & Digit
Next i
'
End Function

and in A1 use this formula:

=IF(A1="","",digits(A1))

(and copy down the column)


"tammyn" wrote:

I have a column with data that may contain both text and numbers. Is there a
macro that extracts only the numbers and place them in the adjacent column?
Example:
Column A Column B
Row 1 A12 12
Row 2 BB121 121
Row 3 1E 1
Row 4 13AA 13
Row 5 66 66

Your help is much appreciated! Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default remove non-numeric characters from cells

Hi,

I copied this from a post a few weeks ago, it will work for the examples
posted but goes strange if you start trying to extract numbers from strings
such as

11BB11

=LOOKUP(9.99999999999999E+307,--MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"012345 6789")),ROW(INDIRECT("1:"&LEN(A1)))))

Mike


"tammyn" wrote:

I have a column with data that may contain both text and numbers. Is there a
macro that extracts only the numbers and place them in the adjacent column?
Example:
Column A Column B
Row 1 A12 12
Row 2 BB121 121
Row 3 1E 1
Row 4 13AA 13
Row 5 66 66

Your help is much appreciated! Thanks!

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
Remove all Characters Remains only Numeric Data Hardeep kanwar[_2_] Excel Discussion (Misc queries) 3 May 16th 10 11:29 AM
remove alpha or non-numeric characters from cell mmanis Excel Discussion (Misc queries) 8 August 7th 09 02:39 AM
remove non-numeric characters from a cell SWBodager Excel Discussion (Misc queries) 14 December 16th 05 07:49 PM
need to add/remove characters over thousands of cells Nadia Excel Discussion (Misc queries) 3 June 19th 05 11:38 PM


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

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

About Us

"It's about Microsoft Excel"