Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Delete text from cell containing text and numbers?

Sub RemoveAlphas()
'' Remove alpha characters from a string.
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "[0-9]" Then
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = ""
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = strTemp
Next rngR

End Sub

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

Hi,


A list of product codes that i use includes some cells containing just
numbers and other cells containing numbers and text.

Does anyone know how to create a macro that when run will search the
selection and when it finds a cell containing both text and numbers it
will remove the text from the cell leaving the numbers behind? Is this
possible?

Any help would be much appreciated


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
Using TEXT and &TEXT - display numbers with commas, underline text Gary Excel Discussion (Misc queries) 3 May 5th 23 03:46 AM
Removal of text from a cell containing both text and numbers Paul Gapes Excel Discussion (Misc queries) 1 September 26th 08 05:54 AM
Removing text from a cell with text and numbers DoubleZ Excel Discussion (Misc queries) 2 July 8th 08 10:14 PM
Easiest way to remove text from a cell that has text and numbers? [email protected] Excel Discussion (Misc queries) 2 August 17th 06 06:07 PM
Delete text while numbers remain intact Sugar_grrl Excel Worksheet Functions 2 August 15th 05 05:32 PM


All times are GMT +1. The time now is 11:43 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"