Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
SWBodager
 
Posts: n/a
Default remove non-numeric characters from a cell

How can I remove all non-numeric characters from a cell? I am trying to
figure final grades for all the students in our school. The cells that I am
working with contain the percentage and the appropriate letter grade (i.e. 80
C+, 85B, 101 A+, etc.) The grades can be two or three digit numeric and one
or two characters (may or may not have a space seperating the numbers from
the leters). Thanks for any help on this,
Scott Bodager )
  #2   Report Post  
Biff
 
Posts: n/a
Default

Hi!

Try this:

Assume your data is in the range A1:A100.

In B1 enter this formula and copy down as needed:

=LOOKUP(1000,--LEFT(A1,ROW(INDIRECT("1:"&LEN(A1)))))

Biff

"SWBodager" wrote in message
...
How can I remove all non-numeric characters from a cell? I am trying to
figure final grades for all the students in our school. The cells that I
am
working with contain the percentage and the appropriate letter grade (i.e.
80
C+, 85B, 101 A+, etc.) The grades can be two or three digit numeric and
one
or two characters (may or may not have a space seperating the numbers from
the leters). Thanks for any help on this,
Scott Bodager )



  #3   Report Post  
SWBodager
 
Posts: n/a
Default

Thank you very much for your help. This worked perfectly.

"Biff" wrote:

Hi!

Try this:

Assume your data is in the range A1:A100.

In B1 enter this formula and copy down as needed:

=LOOKUP(1000,--LEFT(A1,ROW(INDIRECT("1:"&LEN(A1)))))

Biff

"SWBodager" wrote in message
...
How can I remove all non-numeric characters from a cell? I am trying to
figure final grades for all the students in our school. The cells that I
am
working with contain the percentage and the appropriate letter grade (i.e.
80
C+, 85B, 101 A+, etc.) The grades can be two or three digit numeric and
one
or two characters (may or may not have a space seperating the numbers from
the leters). Thanks for any help on this,
Scott Bodager )




  #4   Report Post  
Biff
 
Posts: n/a
Default

Glad to help! Thanks for the feedback.

Biff

"SWBodager" wrote in message
...
Thank you very much for your help. This worked perfectly.

"Biff" wrote:

Hi!

Try this:

Assume your data is in the range A1:A100.

In B1 enter this formula and copy down as needed:

=LOOKUP(1000,--LEFT(A1,ROW(INDIRECT("1:"&LEN(A1)))))

Biff

"SWBodager" wrote in message
...
How can I remove all non-numeric characters from a cell? I am trying
to
figure final grades for all the students in our school. The cells that
I
am
working with contain the percentage and the appropriate letter grade
(i.e.
80
C+, 85B, 101 A+, etc.) The grades can be two or three digit numeric and
one
or two characters (may or may not have a space seperating the numbers
from
the leters). Thanks for any help on this,
Scott Bodager )






  #5   Report Post  
Gord Dibben
 
Posts: n/a
Default

Scott

This macro will remove all but numbers and decimal point(if one present)

Also strips spaces. Select range or column first then run.

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

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben Excel MVP

On Mon, 23 May 2005 10:41:18 -0700, SWBodager
wrote:

How can I remove all non-numeric characters from a cell? I am trying to
figure final grades for all the students in our school. The cells that I am
working with contain the percentage and the appropriate letter grade (i.e. 80
C+, 85B, 101 A+, etc.) The grades can be two or three digit numeric and one
or two characters (may or may not have a space seperating the numbers from
the leters). Thanks for any help on this,
Scott Bodager )




  #6   Report Post  
Posted to microsoft.public.excel.misc
REcord deleted error using parameter que
 
Posts: n/a
Default remove non-numeric characters from a cell

Hi Gord,
I don't mean to hijact this thread but your macro may be just what I'm
looking for. However, I am uncertian where to enter the details of the sheet
and range if the data to be modified is always in the same sheet and range
(other than the sumary sheet that summarises the data). In otehr words I
don't want to have to select the ranges to be changed each time.

I would appreciate any help you can offer. If necessary I will start a new
thread.

Cheers
Jim

"Gord Dibben" wrote:

Scott

This macro will remove all but numbers and decimal point(if one present)

Also strips spaces. Select range or column first then run.

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

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben Excel MVP

On Mon, 23 May 2005 10:41:18 -0700, SWBodager
wrote:

How can I remove all non-numeric characters from a cell? I am trying to
figure final grades for all the students in our school. The cells that I am
working with contain the percentage and the appropriate letter grade (i.e. 80
C+, 85B, 101 A+, etc.) The grades can be two or three digit numeric and one
or two characters (may or may not have a space seperating the numbers from
the leters). Thanks for any help on this,
Scott Bodager )



  #7   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben
 
Posts: n/a
Default remove non-numeric characters from a cell

Jim

Just hard-code the Sheet and Range.

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 = Sheets("Sheet1").Range("E1:H20") _
..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


Gord
On Mon, 12 Dec 2005 00:37:05 -0800, "REcord deleted error using parameter que"
icrosoft.com wrote:

Hi Gord,
I don't mean to hijact this thread but your macro may be just what I'm
looking for. However, I am uncertian where to enter the details of the sheet
and range if the data to be modified is always in the same sheet and range
(other than the sumary sheet that summarises the data). In otehr words I
don't want to have to select the ranges to be changed each time.

I would appreciate any help you can offer. If necessary I will start a new
thread.

Cheers
Jim

"Gord Dibben" wrote:

Scott

This macro will remove all but numbers and decimal point(if one present)

Also strips spaces. Select range or column first then run.

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

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben Excel MVP

On Mon, 23 May 2005 10:41:18 -0700, SWBodager
wrote:

How can I remove all non-numeric characters from a cell? I am trying to
figure final grades for all the students in our school. The cells that I am
working with contain the percentage and the appropriate letter grade (i.e. 80
C+, 85B, 101 A+, etc.) The grades can be two or three digit numeric and one
or two characters (may or may not have a space seperating the numbers from
the leters). Thanks for any help on this,
Scott Bodager )



  #8   Report Post  
Posted to microsoft.public.excel.misc
REcord deleted error using parameter que
 
Posts: n/a
Default remove non-numeric characters from a cell

Thanks Gord,
I had tried that and kept getting the reply "no cells were found". So I
added "ActiveWorkbook", hoping to fix it. Same result.

This is my code:
Set rngRR = ActiveWorkbook.Sheets("UC GST Lgr SUM").Range("I11:I12") _
.SpecialCells(xlCellTypeConstants, _
xlTextValues)

I hate to be a pest but would very much appreciate if you could identify my
error.

Cheers
Jim



"Gord Dibben" wrote:

Jim

Just hard-code the Sheet and Range.

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 = Sheets("Sheet1").Range("E1:H20") _
..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


Gord
On Mon, 12 Dec 2005 00:37:05 -0800, "REcord deleted error using parameter que"
icrosoft.com wrote:

Hi Gord,
I don't mean to hijact this thread but your macro may be just what I'm
looking for. However, I am uncertian where to enter the details of the sheet
and range if the data to be modified is always in the same sheet and range
(other than the sumary sheet that summarises the data). In otehr words I
don't want to have to select the ranges to be changed each time.

I would appreciate any help you can offer. If necessary I will start a new
thread.

Cheers
Jim

"Gord Dibben" wrote:

Scott

This macro will remove all but numbers and decimal point(if one present)

Also strips spaces. Select range or column first then run.

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

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben Excel MVP

On Mon, 23 May 2005 10:41:18 -0700, SWBodager
wrote:

How can I remove all non-numeric characters from a cell? I am trying to
figure final grades for all the students in our school. The cells that I am
working with contain the percentage and the appropriate letter grade (i.e. 80
C+, 85B, 101 A+, etc.) The grades can be two or three digit numeric and one
or two characters (may or may not have a space seperating the numbers from
the leters). Thanks for any help on this,
Scott Bodager )



  #9   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben
 
Posts: n/a
Default remove non-numeric characters from a cell

The Sub will error out if no text to be found in range.

Could be all numbers, blanks, formulas or a combination.

Try this error-trapped version.


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
On Error Resume Next
Set rngRR = Sheets("Sheet1").Range("E1:H20") _
.SpecialCells(xlCellTypeConstants, _
xlTextValues)

On Error GoTo endit
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
Exit Sub
endit:
MsgBox "No text values in range"

End Sub


Gord

On Mon, 12 Dec 2005 17:52:02 -0800, "REcord deleted error using parameter que"
icrosoft.com wrote:

Thanks Gord,
I had tried that and kept getting the reply "no cells were found". So I
added "ActiveWorkbook", hoping to fix it. Same result.

This is my code:
Set rngRR = ActiveWorkbook.Sheets("UC GST Lgr SUM").Range("I11:I12") _
.SpecialCells(xlCellTypeConstants, _
xlTextValues)

I hate to be a pest but would very much appreciate if you could identify my
error.

Cheers
Jim



"Gord Dibben" wrote:

Jim

Just hard-code the Sheet and Range.

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 = Sheets("Sheet1").Range("E1:H20") _
..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


Gord
On Mon, 12 Dec 2005 00:37:05 -0800, "REcord deleted error using parameter que"
icrosoft.com wrote:

Hi Gord,
I don't mean to hijact this thread but your macro may be just what I'm
looking for. However, I am uncertian where to enter the details of the sheet
and range if the data to be modified is always in the same sheet and range
(other than the sumary sheet that summarises the data). In otehr words I
don't want to have to select the ranges to be changed each time.

I would appreciate any help you can offer. If necessary I will start a new
thread.

Cheers
Jim

"Gord Dibben" wrote:

Scott

This macro will remove all but numbers and decimal point(if one present)

Also strips spaces. Select range or column first then run.

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

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben Excel MVP

On Mon, 23 May 2005 10:41:18 -0700, SWBodager
wrote:

How can I remove all non-numeric characters from a cell? I am trying to
figure final grades for all the students in our school. The cells that I am
working with contain the percentage and the appropriate letter grade (i.e. 80
C+, 85B, 101 A+, etc.) The grades can be two or three digit numeric and one
or two characters (may or may not have a space seperating the numbers from
the leters). Thanks for any help on this,
Scott Bodager )



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
Numeric content in one cell ( implicit formula ) and the result in another one PeDevillers Excel Discussion (Misc queries) 7 March 2nd 05 07:40 AM
Maximum characters that can be displayed in a cell Sandeeep Excel Discussion (Misc queries) 2 February 28th 05 05:39 PM
limit number of characters in a cell abfabrob Excel Discussion (Misc queries) 9 February 11th 05 04:19 PM
Visible cell characters sixtyseven67 Excel Discussion (Misc queries) 1 February 7th 05 09:05 PM
#### error if cell has more than 255 characters Budalacovyek Excel Discussion (Misc queries) 1 December 8th 04 06:42 PM


All times are GMT +1. The time now is 05:12 AM.

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"