Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default convert to number

I have a coulmn of numbers that need converted to numbers. The format cell
won't work... You highlight all the numbers and the little ! box comes on and
you click convert to number. However, it does not record that function in a
macro.. I need to do this as it is part of a vlookup macro...
Thanks,
DJ
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default convert to number

Here is some code that I use. It converts the selected numbers to text. You
can highlight entire columns or just a few cells. It leaves formulas alone...

HTH

Public Sub Convert()
Dim rngCurrent As Range
Dim rngToSearch As Range

Set rngToSearch = Intersect(ActiveSheet.UsedRange, Selection)
If Not rngToSearch Is Nothing Then
Application.Calculation = xlCalculationManual
For Each rngCurrent In rngToSearch
If Left(rngCurrent.Value, 1) < "=" Then
rngCurrent.NumberFormat = "@"
rngCurrent.Value = Trim(CStr(rngCurrent.Value))
End If
Next
Application.Calculation = xlCalculationAutomatic
End If
End Sub

"Duncan_J" wrote:

I have a coulmn of numbers that need converted to numbers. The format cell
won't work... You highlight all the numbers and the little ! box comes on and
you click convert to number. However, it does not record that function in a
macro.. I need to do this as it is part of a vlookup macro...
Thanks,
DJ

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default convert to number

Sorry that is my convert to text. I usually use that one when I need
vlookups. To make this convert to number change

rngCurrent.NumberFormat = "@"
rngCurrent.Value = Trim(CStr(rngCurrent.Value))

to

if isnumeric (rngCurrent.Value ) then
rngCurrent.NumberFormat = "#"
rngCurrent.Value = Cdbl(rngCurrent.Value)
end if

HTH

"Jim Thomlinson" wrote:

Here is some code that I use. It converts the selected numbers to text. You
can highlight entire columns or just a few cells. It leaves formulas alone...

HTH

Public Sub Convert()
Dim rngCurrent As Range
Dim rngToSearch As Range

Set rngToSearch = Intersect(ActiveSheet.UsedRange, Selection)
If Not rngToSearch Is Nothing Then
Application.Calculation = xlCalculationManual
For Each rngCurrent In rngToSearch
If Left(rngCurrent.Value, 1) < "=" Then
rngCurrent.NumberFormat = "@"
rngCurrent.Value = Trim(CStr(rngCurrent.Value))
End If
Next
Application.Calculation = xlCalculationAutomatic
End If
End Sub

"Duncan_J" wrote:

I have a coulmn of numbers that need converted to numbers. The format cell
won't work... You highlight all the numbers and the little ! box comes on and
you click convert to number. However, it does not record that function in a
macro.. I need to do this as it is part of a vlookup macro...
Thanks,
DJ

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default convert to number

Copy an empty cell.
select your column
edit|paste special|check Add

or

Select your column
data|text to columns|finish.

Duncan_J wrote:

I have a coulmn of numbers that need converted to numbers. The format cell
won't work... You highlight all the numbers and the little ! box comes on and
you click convert to number. However, it does not record that function in a
macro.. I need to do this as it is part of a vlookup macro...
Thanks,
DJ


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default convert to number

Thanks for the help!
Both worked...
DJ

"Dave Peterson" wrote:

Copy an empty cell.
select your column
edit|paste special|check Add

or

Select your column
data|text to columns|finish.

Duncan_J wrote:

I have a coulmn of numbers that need converted to numbers. The format cell
won't work... You highlight all the numbers and the little ! box comes on and
you click convert to number. However, it does not record that function in a
macro.. I need to do this as it is part of a vlookup macro...
Thanks,
DJ


--

Dave Peterson



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 number to % using only custom number format challenge Brotherharry Excel Discussion (Misc queries) 7 June 2nd 09 06:29 PM
how do I convert a number to number of years, months and days because Excel Worksheet Functions 2 October 12th 05 06:15 PM
convert text-format number to number in excel 2000%3f Larry Excel Discussion (Misc queries) 1 July 29th 05 08:18 PM
not able to convert text, or graphic number to regular number in e knutsenk Excel Worksheet Functions 1 April 2nd 05 08:41 AM
convert decimal number to time : convert 1,59 (minutes, dec) to m agenda9533 Excel Discussion (Misc queries) 8 January 20th 05 10:24 PM


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