Jump to content

convert String to Number in worksheets


Recommended Posts

is there a function for this ?

 

I have a text field in a record format, populated with numbers and I need to multilpicate this with a count field in a worksheet.

And yes, I could convert the field in the record format, but I want to keep this as text field for other entries.

Link to comment
2 hours ago, halfcoupler said:

but I want to keep this as text field for other entries.

 

Hmm if this is in a database + you have non-numerical text in some instances of that field =VALUE will return an error in those cases...

  • Like 2
Link to comment

Great! works perfect! Thank you!

 

20 minutes ago, Tom W. said:

Hmm if this is in a database + you have non-numerical text in some instances of that field =VALUE will return an error in those cases...

 

No Problem since I am filtering out all non numeric values by database criteria in the worksheet.

 

Link to comment

Just to be clear, that non-numerical includes things like unit marks and thousands separators.

 

 So 1000.01 will work in the US.  I believe it will fail in a region using the comma as the decimal point.

 

These will all fail to convert to numbers

1,000.01

1000.01 mm

$1000.01

 

 

Link to comment

Hi Pat, just tested it, it seems the Value function follows the setting in the operating system. Working on a German Windows version, it can handle a value like 43,4868 but it can not handle not 43.4868 .

It fails when having anything else than numbers or the decimal separator in the string.

You are right, this is a buggy solution,- the correct way is to use the appropriate data type in the record format.

 

But I was just looking for a quick & dirty way to do some simple calculations on a few symbols, when there is no other record field available in my record format.

Edited by halfcoupler
Link to comment

The results you got were exactly what I expected.

 

It is a good quick and dirty way to get a number.  But only if your data is formatted properly.

 

"Text Mangling" is not worksheet strong point (or Vectorscript for that matter), but if you have a fairly uniform data format we might be able to extract just the numeric part out to use Value on.

 

Something like =Value(Mid(A1, 2, 6)) where A1 contains '€345,67 per meter' would return a number of 345,67.

 

Much harder to do if you don't have a prefix and a length or suffix of fixed lengths or if you need to remove thousands separators inside the number string.

 

Ask If you need help.

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...