+ Reply to Thread
Results 1 to 12 of 12

Customising the TEXT(Value,"Format") Function for Indian Currency

  1. #1
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Customising the TEXT(Value,"Format") Function for Indian Currency

    Customising a TEXT(Value,"Format") for Indain Currency

    I use a particular format for displaying numeric values as money in Indian Rupees with appropriate commas after Thousands and Lakhs..

    I have the following two formats to be used in the FORMAT CELL for the Numeric values where Money or Currency has to be displayed..

    1. [>9999999]"Rs "#\,##\,##\,##0;[>99999]"Rs "#\,##\,##0;"Rs "#,##0 without dedimal points.
    Ex:- 125999 -->> Rs 1,25,999

    2. [>9999999]"Rs "#\,##\,##\,##0.00;[>99999]"Rs "#\,##\,##0.00;"Rs "#,##0.00 with decimal points upto 2 decimal places...Ex:- 125999 -->> Rs 1,25,999.00

    Now this works fantastically for numeric entries, however I need to use the same format when using in a sentence such as Rs 1,25,999 for the XYZ expense..

    So how do I customise the same in the TEXT Function..?

    What FORMAT do I use in the TEXT Functions parameter to get the same result using it in a sentence..

    Regards
    e4excel
    Last edited by e4excel; 02-11-2011 at 01:49 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    Try:

    TEXT(A1,"[>9999999]""Rs ""#\,##\,##\,##0;[>99999]""Rs ""#\,##\,##0;""Rs ""#,##0")

    note the doubling up of quotes.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    Quote Originally Posted by NBVC View Post
    Try:

    TEXT(A1,"[>9999999]""Rs ""#\,##\,##\,##0;[>99999]""Rs ""#\,##\,##0;""Rs ""#,##0")

    note the doubling up of quotes.
    Thanks a Lot NBVC, it works...

    "[>9999999]""Rs ""#\,##\,##\,##0;[>99999]""Rs ""#\,##\,##0;""Rs ""#,##0")

    I am not mentioning the above code in TAGS as just want to confirm that the 2 X Double quotes which are in RED font and thats the only difference..

    As I had tried using it normally and it failed...

    Can you please explain how this format is constructed as I am using it from an existing template.. almost blindly

    Regards
    E

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    Yes those are the only changes...

    Since the "format" part of the text function itself has to be enclosed in quotes, you have to double up the inside quotes, so that the function doesn't interpret the second quote (before the first RS) as a closing quote...

    Have a look at these 2 links to help you understand custom formatting....

    http://www.ozgrid.com/Excel/CustomFormats.htm

    http://peltiertech.com/Excel/NumberFormats.html

  5. #5
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    Thanks a loT NBVC,

    Good links to refer whenever I hit the wall in such formats..

    God bless..!

    Regards
    e4excel

  6. #6
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    Dear NBVC,

    The solution provided indeed worked well in the Sheets in the formula but will it work the same way in VBA code..

    As I am trying to use the same format in VBA, but it gives me a different result than desired..

    Format(Sheets(NewSheetName).Cells(8, 10), "[>9999999]""Rs ""#\,##\,##\,##0;[>99999]""Rs ""#\,##\,##0;""Rs ""#,##0")
    The value such as this 39371 in the Formula is correctly shown as Rs 39,371.00
    is being shown as Rs ,,39,371.

    Please advise, I know that the thread is SOLVED however I just tried using the same thing in VBA..

    Warm Regards
    e4excel

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    I am probably not the best person to come to for VBA, but if I create a simple sub:

    Please Login or Register  to view this content.
    It works fine and displays as: Rs 39,371.00

  8. #8
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    My sincere apologies for not being able to explain precisely but thats to do more with my VBA lacunae...
    I was trying to use the format not in a cell but in a Comment alongwith other Text Strings...
    So, please pardon me for any inconveniece caused to you over this..
    Nevertheless, that really worked in gettting the desired format in a cell using VBA and with this solution I learnt something about the .NumberFormat option in VBA..


    Thanks NBVC,

    That works brilliantly in VBA setup..but the only problem is that I was using this to store it in a String variable to be used in a Comment..

    Sheets("NewSheetName").Cells(8, 10).Value = 39371
    The actual value in this cell is a Number 39371 and using the formatting in the FOrmat cell I get to display it as Rs 39,371.00 and with your help in the posts # 2
    TEXT(A1,"[>9999999]""Rs ""#\,##\,##\,##0;[>99999]""Rs ""#\,##\,##0;""Rs ""#,##0")
    I could use the above format while using it in Concatenated Text too!

    However, I am trying to use this value to be Added in a Comment with the Formatting.

    So, my Novice VBA code goes like this

    Dim Comm As String
    Comm = "Opening Balance" & char(10) &Sheets("NewSheetName").Cells(8, 10).Value
    Sheets(NewSheetName).Cells(8, 10).AddComment Text:=Comm
    Sheets(NewSheetName).Cells(8, 10).Comment.Visible = True
    But when I tried this it simply gave me only the number as 39371 in the comment..
    So, I tried using the format option as mentioned in my post # 6

    Format(Sheets(NewSheetName).Cells(8, 10), "[>9999999]""Rs ""#\,##\,##\,##0;[>99999]""Rs ""#\,##\,##0;""Rs ""#,##0")
    it gave me this Rs,,39371

    But I need to get it as this in the Comment:

    "Opening Balance"
    Rs 39,371,00


    So, its kinda using the Number Format in a TEXT option the way you showed me in the POST #2 however for VBA and more importantly in the Comments which is shown wit the variable Comm as String..

    Warm Regards
    e4excel
    Last edited by e4excel; 03-11-2011 at 07:15 AM.

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    Perhaps try using the Excel Worksheet Function: Text

    E.g.

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    Quote Originally Posted by NBVC View Post
    Perhaps try using the Excel Worksheet Function: Text

    E.g.

    Please Login or Register  to view this content.
    Perhaps was an Understatement, it worked well to produce the desires result..

    Thanks a lot NBVC for helping again and seeing it till the end..

    P.S. Just had a small correction With Sheets(NewSheetName) as this was a String Variable used for new Sheets..

    Warm Regards
    e4excel

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    Quote Originally Posted by e4excel View Post
    P.S. Just had a small correction With Sheets(NewSheetName) as this was a String Variable used for new Sheets..

    Warm Regards
    e4excel
    Yeah, I wasn't sure about that... but in order to make it work for my sample, I named the actual sheet as NewSheetName... that is the reason for the quotes around the name....

  12. #12
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Customising the TEXT(Value,"Format") Function for Indian Currency

    Thanks once again...

    I knew that, that was not a mistake on your part but I mentioned incase someone's checking for similar help would find it useful..


    Warm Regards
    e4excel

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1