ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do you convert $100M into a whole number? (https://www.excelbanter.com/excel-worksheet-functions/112664-how-do-you-convert-%24100m-into-whole-number.html)

Jerry Lee Penny

How do you convert $100M into a whole number?
 
As above assuming it is possible. Have tried copy and special paste without
much luck so far.

Marcelo

How do you convert $100M into a whole number?
 
Hi Jerry,

copy this code (press alt+f11) and use in an auxiliar column
=digitsonly(a2)

***********************************************
Public Function DigitsOnly(sStr As String) As Variant
Dim oRegExp As Object

Set oRegExp = CreateObject("VBScript.RegExp")

With oRegExp
.IgnoreCase = True
.Global = True
oRegExp.Pattern = "\D"

DigitsOnly = oRegExp.Replace(sStr, vbNullString)
End With
End Function
***********************************************

hth
--
regards from Brazil
Thanks in advance for your feedback.
Marcelo



"Jerry Lee Penny" escreveu:

As above assuming it is possible. Have tried copy and special paste without
much luck so far.


[email protected]

How do you convert $100M into a whole number?
 
Jerry Lee Penny wrote:
Subject: How do you convert $100M into a whole number?
As above assuming it is possible. Have tried copy and special paste without
much luck so far.


[Please repeat the question in the body of the posting.]

Do you mean that you have the text "$100M"? If so, does the following
meet your needs, assuming that A1 contains the text to convert:

1000000*mid(A1, 2, len(A1)-2)

More robust:

if(isnumber(A1), A1, if(right(A1,1)="M", 1000000*mid(A1,2,len(A1)-2),
if(right(A1,1)="K", 1000*mid(A1,2,len(A1)-2), 1*right(A1,len(A1)-1))))



All times are GMT +1. The time now is 08:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com