Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben
 
Posts: n/a
Default question about removing text from cells, leaving numbers

Macro OK with you?

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

After losing all the text, do a text to columnsfixed width to split out to
seperate cells.


Gord Dibben Excel MVP

On Sun, 27 Nov 2005 23:32:36 -0600, JPN5804
wrote:


This forum has already proved helpful, I've already gotten help for a
problem.

I've got another problem, however. I've got a large number of cells
with both numbers and text, I need to extract the text, leaving the
numbers so I can add them. The problem is, the number of characters
varies. Here are some examples of cells:

"3 I am so sad or unhappy that I can't stand it., 2 I am sad all the
time and I can't snap out of it., 1 I feel sad."

I need to remove the text, leaving the 3 and the two, then I could do
text to columns to get the 3 and 2 into their own cells. The problem
is, I the number of characters varies, for example, another cell
contains "3 I am very sad., 2 I am somewhat sad."

Thanks again.


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
Linked cells and text boxes Alexlondon11 Excel Discussion (Misc queries) 2 November 23rd 05 04:10 PM
adding cells which include numbers and text Shelley Excel Discussion (Misc queries) 1 October 25th 05 07:50 AM
How to alter data on HTML webpage into Excell cells as numbers? roameri New Users to Excel 6 July 31st 05 11:42 PM
Cells formated as text do not always display properly Cass Excel Discussion (Misc queries) 2 July 23rd 05 01:59 AM
Removing numbers from the beginning of a text string Night Owl Excel Worksheet Functions 3 May 13th 05 05:52 PM


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