Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using TEXT and &TEXT - display numbers with commas, underline text | Excel Discussion (Misc queries) | |||
Removal of text from a cell containing both text and numbers | Excel Discussion (Misc queries) | |||
Removing text from a cell with text and numbers | Excel Discussion (Misc queries) | |||
Easiest way to remove text from a cell that has text and numbers? | Excel Discussion (Misc queries) | |||
Delete text while numbers remain intact | Excel Worksheet Functions |