Consulting

Results 1 to 7 of 7

Thread: Convert % value to text using IF

  1. #1
    VBAX Tutor joelle's Avatar
    Joined
    Apr 2005
    Location
    Sunnyvale, CA
    Posts
    204
    Location

    Convert % value to text using IF

    Hello Experts,

    Is there a way to set an IF statement to convert a % value to text.
    for example:
    cell B1 is for a discount percent (10.25%)
    then the IF formula in C1 would be:
    if B1 is > 0,
    then
    C1 equals to B1 but in "text" format,
    otherwise, C1 is blank.

    Please help me with this IF in C1.
    Thanks a lot,
    Nee

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try
    =IF(B1>0,TEXT(B1,"0.00%"),"")
    or if you don't want a formula in the cell, this function will put the text only into the corresponding cell in column C


    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Column() = 2 Then
            Selection.NumberFormat = "@"
            Target.Offset(0, 1).Formula = Target * 100 & "%"
        End If
    End Sub
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Tutor joelle's Avatar
    Joined
    Apr 2005
    Location
    Sunnyvale, CA
    Posts
    204
    Location
    Hello mdmackillop,

    Thanks a lot for the quick reply.
    Yes, I did try a "similar" formula in the past but it did not work properly
    in Europe (I'm in USA).
    I used this (for 14.25%):
    =IF(B1>0,TEXT(B1,"##.##%"),"")
    and in Europe, they saw this 142.5% !!!

    Was it because I used ##.##% instead of having to use 0.00%
    as in your formula??
    This is much simpler than vba if works. I'll change my formula to
    =IF(B1>0,TEXT(B1,"0.00%"),"")
    and will ask them to test it.

    I'll let you know. Thanks a lot and have a Great 4th!
    (it's my sister birthday too, not mine )

    Best regards,
    Nee

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Nee
    Yes, I did try a "similar" formula in the past but it did not work properly
    in Europe (I'm in USA).
    I used this (for 14.25%):
    =IF(B1>0,TEXT(B1,"##.##%"),"")
    and in Europe, they saw this 142.5% !!!

    Was it because I used ##.##% instead of having to use 0.00%
    as in your formula??
    This is much simpler than vba if works. I'll change my formula to
    =IF(B1>0,TEXT(B1,"0.00%"),"") and will ask them to test it.
    I'm in Europe, and your format gives 14.25% for me. There is no actual reason why MDs formula would work and yours not, the difference is that his would show 14% as 14.00%, yours would show as 14.%.

    That is a very odd situation.

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Nee,
    I have no problem with your formula either!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    VBAX Tutor joelle's Avatar
    Joined
    Apr 2005
    Location
    Sunnyvale, CA
    Posts
    204
    Location
    Hello XLD and MD,

    Wow - I'm impressed by the quick writeback - like you guys are just in my neighborhood (I wish!)

    Thank you much XLD for looking at my formula from Europe! when I have not heard back from a soul there from my company branch in France/UK ...

    Anyhow, I have no idea about why they saw it differently in the past with the point shifted one place to the right. Right or left -- they are equally bad.

    Anyhow, thanks again and I will go ahead mark this thread solved. After
    that I have to pack up beers for the 4th!
    (who said girls dont like beers?)

    Have a wonderful weekend everyone.
    Nee

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Nee
    Thank you much XLD for looking at my formula from Europe! when I have not heard back from a soul there from my company branch in France/UK ...

    Anyhow, I have no idea about why they saw it differently in the past with the point shifted one place to the right. Right or left -- they are equally bad.
    There might be an issue in France, as they use . (dot) as a thousands separator, and , (Comma) as the decimal separator.

    Quote Originally Posted by Nee
    (who said girls dont like beers?)

    Have a wonderful weekend everyone.
    All the girls I know like beer (except my daughters ). No point in knowing them if they didn't

    Enjoy the fourth.

Posting Permissions

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