Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How to change alphanumeric to numeric

Hi,

I have bunch of "numbers" in column 1 like

2
9
15
71
8

but when I sort, the 9 is at the bottom of the list because it is not truly
numeric.

From what I've read in this forun, I was able to identify the cells that are
not numeric by using:

Sub test()
Dim rng As Range

Set rng = ActiveSheet.Columns(1).SpecialCells(xlConstants, xlTextValues)
rng.Select
End Sub

Now that I am able to identify the locations of the cells, is there a quick
way to change them to numeric values?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default How to change alphanumeric to numeric

My favourite 'trick' for performing this task is to multiply everything
(including text) by 1. This forces numbers to be treated as such.

The quickest way to do it is to copy a cell containing the number 1 and
PasteSpecial values with operation 'multiply'.

HTH

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default How to change alphanumeric to numeric

Since you have narrowed down the data set this is not too bad to do...

Sub test()
Dim rng As Range
Dim rngCurrent as Range

Set rng = ActiveSheet.Columns(1).SpecialCells(xlConstants, xlTextValues)
for each rngCurrent in rng
If IsNumeric(rngCurrent.Value) Then
rngCurrent.NumberFormat = "0"
rngCurrent.Value = CDbl(rngCurrent.Value)
rngCurrent.Formula = rngCurrent.Value
End If
next rngCurrent
--
HTH...

Jim Thomlinson


"borg" wrote:

Hi,

I have bunch of "numbers" in column 1 like

2
9
15
71
8

but when I sort, the 9 is at the bottom of the list because it is not truly
numeric.

From what I've read in this forun, I was able to identify the cells that are
not numeric by using:

Sub test()
Dim rng As Range

Set rng = ActiveSheet.Columns(1).SpecialCells(xlConstants, xlTextValues)
rng.Select
End Sub

Now that I am able to identify the locations of the cells, is there a quick
way to change them to numeric values?

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How to change alphanumeric to numeric

Thank you! It works great!



"Jim Thomlinson" wrote:

Since you have narrowed down the data set this is not too bad to do...

Sub test()
Dim rng As Range
Dim rngCurrent as Range

Set rng = ActiveSheet.Columns(1).SpecialCells(xlConstants, xlTextValues)
for each rngCurrent in rng
If IsNumeric(rngCurrent.Value) Then
rngCurrent.NumberFormat = "0"
rngCurrent.Value = CDbl(rngCurrent.Value)
rngCurrent.Formula = rngCurrent.Value
End If
next rngCurrent
--
HTH...

Jim Thomlinson


"borg" wrote:

Hi,

I have bunch of "numbers" in column 1 like

2
9
15
71
8

but when I sort, the 9 is at the bottom of the list because it is not truly
numeric.

From what I've read in this forun, I was able to identify the cells that are
not numeric by using:

Sub test()
Dim rng As Range

Set rng = ActiveSheet.Columns(1).SpecialCells(xlConstants, xlTextValues)
rng.Select
End Sub

Now that I am able to identify the locations of the cells, is there a quick
way to change them to numeric values?

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
Alphanumeric Sorting - numeric alpha numeric Mike Excel Worksheet Functions 2 September 15th 08 10:12 PM
Obtain numeric from alphanumeric string Manj Excel Discussion (Misc queries) 3 March 14th 08 01:28 PM
VLOOKUP with numeric and alphanumeric values Dan Excel Discussion (Misc queries) 6 November 2nd 07 04:59 PM
Converting Alphanumeric numbers to Numeric Lowkey Excel Worksheet Functions 3 May 8th 06 11:24 PM
VBA - Looking to strip alphanumeric from numeric Dingo[_2_] Excel Programming 2 January 30th 04 06:52 PM


All times are GMT +1. The time now is 07:48 AM.

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

About Us

"It's about Microsoft Excel"