Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old September 13th 06, 02:43 PM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
First recorded activity by ExcelBanter: Jul 2006
Posts: 112
Default Convert Text to Numbers in a Macro

Hi! I have a data dump I am running several macros on. One macro I would
love to run is to convert a column of text numbers to numerical.

Excel does recognize them - I get the little green tirangle. But anyone who
uses Excel XP or 2003 (which I do) knows that formatting does NOT work.
Conversion must be done using that Smart Tag option.

However, the smart tag action does not get recorded in a macro. Microsoft
gave us a wonderful new feature and then didn't let us record it and make
life alittle easier.

So, if anyone can help me find a way to get this action recorded into the
macro, I would be forever grateful and even have monks pray for you.


  #2   Report Post  
Old September 13th 06, 03:04 PM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
First recorded activity by ExcelBanter: Aug 2006
Posts: 341
Default Convert Text to Numbers in a Macro

How long this takes will depend how many cells you have with values in.
It took me 25 seconds to process for one column with all 65536 rows, on a p4
1800 with 500mb memory. You can cut that by using For each rg in
Range("A1:A1000"), for example.

Sub TryThis()

Application.ScreenUpdating = False
Dim rg As Range

For Each rg In Range("A:A")

If rg.Value < "" Then
rg.NumberFormat = "General"
rg.Value = rg.Value
End If

Next rg
Application.ScreenUpdating = True

End Sub

I am looking forward to hearing those monks.
Alternatively you could be very nice and give me a little green tick :-)
--
Allllen


"Denise" wrote:

Hi! I have a data dump I am running several macros on. One macro I would
love to run is to convert a column of text numbers to numerical.

Excel does recognize them - I get the little green tirangle. But anyone who
uses Excel XP or 2003 (which I do) knows that formatting does NOT work.
Conversion must be done using that Smart Tag option.

However, the smart tag action does not get recorded in a macro. Microsoft
gave us a wonderful new feature and then didn't let us record it and make
life alittle easier.

So, if anyone can help me find a way to get this action recorded into the
macro, I would be forever grateful and even have monks pray for you.

  #3   Report Post  
Old September 13th 06, 03:24 PM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
First recorded activity by ExcelBanter: Jul 2006
Posts: 5,441
Default Convert Text to Numbers in a Macro

Denise,

Instead of doing it setpwise, you can do it all at once. The macro below will convert all text
string numbers in column A of the active sheet to actual numbers.

It should only take a blink to do it. It just requires that row 1 not be filled all the way to
column IV... You can change the format from general to a specific number format if you want to
format the text numbers in a specific way:

..NumberFormat = "0.00"

to show two decimal places, for example....

HTH,
Bernie
MS Excel MVP

Sub ConvertTextNumbersToNumbers()
Dim mySel As Range
Dim myCell As Range

Set mySel = Selection

Set myCell = Range("IV1").End(xlToLeft)(1, 2)

On Error Resume Next
With myCell
..NumberFormat = "general"
..Value = 1
..Copy
Range("A:A").SpecialCells(xlCellTypeConstants, 2).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlMultiply
..Clear
End With

mySel.Select

End Sub


"Denise" wrote in message
...
Hi! I have a data dump I am running several macros on. One macro I would
love to run is to convert a column of text numbers to numerical.

Excel does recognize them - I get the little green tirangle. But anyone who
uses Excel XP or 2003 (which I do) knows that formatting does NOT work.
Conversion must be done using that Smart Tag option.

However, the smart tag action does not get recorded in a macro. Microsoft
gave us a wonderful new feature and then didn't let us record it and make
life alittle easier.

So, if anyone can help me find a way to get this action recorded into the
macro, I would be forever grateful and even have monks pray for you.



  #4   Report Post  
Old September 13th 06, 03:25 PM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
First recorded activity by ExcelBanter: Jul 2006
Posts: 112
Default Convert Text to Numbers in a Macro

Expect a bucket load of prayers ))))))))

"Allllen" wrote:

How long this takes will depend how many cells you have with values in.
It took me 25 seconds to process for one column with all 65536 rows, on a p4
1800 with 500mb memory. You can cut that by using For each rg in
Range("A1:A1000"), for example.

Sub TryThis()

Application.ScreenUpdating = False
Dim rg As Range

For Each rg In Range("A:A")

If rg.Value < "" Then
rg.NumberFormat = "General"
rg.Value = rg.Value
End If

Next rg
Application.ScreenUpdating = True

End Sub

I am looking forward to hearing those monks.
Alternatively you could be very nice and give me a little green tick :-)
--
Allllen


"Denise" wrote:

Hi! I have a data dump I am running several macros on. One macro I would
love to run is to convert a column of text numbers to numerical.

Excel does recognize them - I get the little green tirangle. But anyone who
uses Excel XP or 2003 (which I do) knows that formatting does NOT work.
Conversion must be done using that Smart Tag option.

However, the smart tag action does not get recorded in a macro. Microsoft
gave us a wonderful new feature and then didn't let us record it and make
life alittle easier.

So, if anyone can help me find a way to get this action recorded into the
macro, I would be forever grateful and even have monks pray for you.



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
Convert numbers to text Gary Hopkins Excel Discussion (Misc queries) 7 July 14th 06 05:57 PM
Convert Text to Numbers Jitty Excel Worksheet Functions 2 May 9th 06 02:30 PM
How can I convert Text into numbers? Greta Excel Worksheet Functions 8 August 22nd 05 02:03 PM
Convert text to numbers vipa2000 Excel Worksheet Functions 3 August 1st 05 09:01 PM
How to convert Excel imported numbers from text to numbers? Alden Excel Discussion (Misc queries) 9 April 1st 05 09:51 PM


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

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

About Us

"It's about Microsoft Excel"

 

Copyright © 2017