Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Converting Text to Numeric

I have a spreadsheet that is drawn from a real-time
databse. The cells I need to work with are text formatted
with numbers having commas and decimals (e.g. 1,000.00).
Excel has a function called VALUE()which can convert a
text string to numeric, but it is not available in VBA.
VBA does have a similar function called Val(), but it
won't work if the text string has commas.

Can anyone suggest a VBA function or subroutine that can
convert a text string having numbers with commas to
numeric? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Converting Text to Numeric

Mat

Try using the substitute function

Val(WorksheetFunction.Substitute("1,000.5", ",", "")

Ton

----- Matt wrote: ----

I have a spreadsheet that is drawn from a real-time
databse. The cells I need to work with are text formatted
with numbers having commas and decimals (e.g. 1,000.00).
Excel has a function called VALUE()which can convert a
text string to numeric, but it is not available in VBA.
VBA does have a similar function called Val(), but it
won't work if the text string has commas

Can anyone suggest a VBA function or subroutine that can
convert a text string having numbers with commas to
numeric? Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Converting Text to Numeric

Mat

This should do it


Sub txt2Num()
Dim c
For Each c In Selection
If IsNumeric(c) Then
c.Value = c * 1
c.NumberFormat = "0,000.00" 'Alter foremat to suit
Else
c = c
End If
Next c
End Sub

Regards
Peter
-----Original Message-----
I have a spreadsheet that is drawn from a real-time
databse. The cells I need to work with are text formatted
with numbers having commas and decimals (e.g. 1,000.00).
Excel has a function called VALUE()which can convert a
text string to numeric, but it is not available in VBA.
VBA does have a similar function called Val(), but it
won't work if the text string has commas.

Can anyone suggest a VBA function or subroutine that can
convert a text string having numbers with commas to
numeric? 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
Converting time from text to numeric Eric Wixom[_2_] Excel Worksheet Functions 4 March 21st 08 06:56 PM
Converting Numeric values to Text shail Excel Worksheet Functions 2 September 5th 06 04:50 PM
converting text to numeric data babooz Excel Worksheet Functions 3 May 19th 06 08:14 AM
Converting variable text strings to numeric Richgard53 Excel Discussion (Misc queries) 1 July 13th 05 06:22 AM
Converting Text into a Numeric Value and Totalling Shazbut Excel Worksheet Functions 1 May 10th 05 05:14 PM


All times are GMT +1. The time now is 06:53 PM.

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"