• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Currency Converter Macro

Sameer

New Member
I have this currency converter macro. I am facing trouble in two things


1) When I choose the currency as JPY it shows the "yens" in words instead of "Yen" when we convert any amount greater than 1 yen. In case of JPY it is Yen only even for any amount greater than 1.

2) Secondly(not exactly a macro problem but may be a new macro is required) when we use JPY there are no decimal places. So is it possible that if the currency is yen the amount if figures shows no decimal places otherwise two decimal places in case of other currencies


I am using this macro to manage excel based invoicing.
 
@Sameer


Hi


Welcome to Chandoo Group and Glad you are here


is it possible to post a sample work book with your macro


and it is better to suggest the perfect thing actually what do you want


Thanks


SP
 
Hi Sameer ,


If you are having a problem with any software downloaded from this forum , then you can certainly expect answers by posting your problem here ; but if you have either purchased or downloaded the macro from some other agency / website , then I doubt that you can get answers , unless you can post the macro itself here.


Regarding your first question , you are right that the Yen does not have a plural.


Regarding your second question , Wikipedia says that there are two subunits for the Yen , the Sen and the Rin , but I do not know whether these are in circulation. If they are not , then this may be a reason for the Yen value not to have any decimal places.


Narayan
 
Hi, Sameer!


You wrote "I have this currency converter macro."... but where is the macro? Paste it here or...

Consider uploading a sample file (including manual examples of desired output), it'd be very useful for those who read this and might be able to help you. Thank you.

Give a look at the green sticky posts at this forums main page for uploading guidelines.


Regards!
 
Hi,


Please download the file from here :


https://www.dropbox.com/s/uraihq74igjn8nd/SpellCurrency.xls?m
 
Hi Sameer ,


The file you have uploaded does not contain any currency converter macro ; what it contains is a macro that converts figures or numbers to text , and either prefixes or suffixes the currency string to this converted text.


The macro does not care what the currency is ; as long as the value is greater than 1 , it uses the plural of the currency text that you have specified ; if it is Rupee , it makes it Rupees , if it is dollar , it makes it dollars , and so on.


Regarding the issue of decimal places , this is not in the purview of the given macro , since the macro itself does not understand any currency ; all it is doing is converting numbers to text.


Narayan
 
Hi, Sameer!


In this site you have an online currency converter, should this help you?

http://www.xe.com/ucc/convert/?Amount=1&From=EUR&To=USD


I assume it wouldn't be fair at all if you profit from this service and steal its processing capabilities each time you need without asking permission to its author, but if you wouldn't care (and I insist you should!) maybe you want to give a look at this file:

https://dl.dropbox.com/u/60558749/Currency%20Converter%20Macro%20%28for%20Sameer%20at%20chandoo.org%29.xlsm


Just advise if any issue.


Regards!
 
I don't know if this is what you need, but I used this cool user defined function to spellnumber.

Paste into your code.

in the cell you want the number spelled out, make the formula '=spellnumber(cell)'

cell, of course is your source number.

'****************' Main Function *'****************

Function SpellNumber(ByVal MyNumber)

Dim Dollars, Cents, Temp

Dim DecimalPlace, Count

ReDim Place(9) As String

Place(2) = " Thousand "

Place(3) = " Million "

Place(4) = " Billion "

Place(5) = " Trillion " ' String representation of amount

MyNumber = Trim(Str(MyNumber)) ' Position of decimal place 0 if none

DecimalPlace = InStr(MyNumber, ".")

'Convert cents and set MyNumber to dollar amount

If DecimalPlace > 0 Then

Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2))

MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))

End If

Count = 1

Do While MyNumber <> ""

Temp = GetHundreds(Right(MyNumber, 3))

If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars

If Len(MyNumber) > 3 Then

MyNumber = Left(MyNumber, Len(MyNumber) - 3)

Else

MyNumber = ""

End If

Count = Count + 1

Loop

Select Case Dollars

Case ""

Dollars = "Zero Dollars"

Case "One"

Dollars = "One Dollar"

Case Else

Dollars = Dollars & " Dollars"

End Select

Select Case Cents

Case ""

Cents = " and Zero Cents"

Case "One"

Cents = " and One Cent"

Case Else

Cents = " and " & Cents & " Cents"

End Select

SpellNumber = Dollars & Cents

End Function

'*******************************************

' Converts a number from 100-999 into text *

'*******************************************

Function GetHundreds(ByVal MyNumber)

Dim Result As String

If Val(MyNumber) = 0 Then Exit Function

MyNumber = Right("000" & MyNumber, 3) 'Convert the hundreds place

If Mid(MyNumber, 1, 1) <> "0" Then

Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "

End If

'Convert the tens and ones place

If Mid(MyNumber, 2, 1) <> "0" Then

Result = Result & GetTens(Mid(MyNumber, 2))

Else

Result = Result & GetDigit(Mid(MyNumber, 3))

End If

GetHundreds = Result

End Function

'*********************************************

' Converts a number from 10 to 99 into text. *

'*********************************************

Function GetTens(TensText)

Dim Result As String

Result = "" 'null out the temporary function value

If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19

Select Case Val(TensText)

Case 10: Result = "Ten"

Case 11: Result = "Eleven"

Case 12: Result = "Twelve"

Case 13: Result = "Thirteen"

Case 14: Result = "Fourteen"

Case 15: Result = "Fifteen"

Case 16: Result = "Sixteen"

Case 17: Result = "Seventeen"

Case 18: Result = "Eighteen"

Case 19: Result = "Nineteen"

Case Else

End Select

Else ' If value between 20-99

Select Case Val(Left(TensText, 1))

Case 2: Result = "Twenty "

Case 3: Result = "Thirty "

Case 4: Result = "Forty "

Case 5: Result = "Fifty "

Case 6: Result = "Sixty "

Case 7: Result = "Seventy "

Case 8: Result = "Eighty "

Case 9: Result = "Ninety "

Case Else

End Select

Result = Result & GetDigit _

(Right(TensText, 1)) 'Retrieve ones place

End If

GetTens = Result

End Function

'*******************************************

' Converts a number from 1 to 9 into text. *

'*******************************************

Function GetDigit(Digit)

Select Case Val(Digit)

Case 1: GetDigit = "One"

Case 2: GetDigit = "Two"

Case 3: GetDigit = "Three"

Case 4: GetDigit = "Four"

Case 5: GetDigit = "Five"

Case 6: GetDigit = "Six"

Case 7: GetDigit = "Seven"

Case 8: GetDigit = "Eight"

Case 9: GetDigit = "Nine"

Case Else: GetDigit = ""

End Select

End Function
 
Back
Top