+ Reply to Thread
Results 1 to 4 of 4

Thread: IF function to determine if a cell is a %

  1. #1
    Forum Contributor
    Join Date
    09-05-2007
    Posts
    111

    IF function to determine if a cell is a %

    I need to use an IF function to determine if a cell is a percentage or not.

    I have data that is a mix of % (cell is %) and normal data(Inlcudes decimal data). How could I differntiate between which is which using an IF?

    Thanks

  2. #2
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    Location: Location
    MS-Off Ver
    Excel 2007
    Posts
    266

    Re: IF function to determine if a cell is a %

    If all percentages are less than 100%, you could just do
    =If(A2<1,"Percentage","Not %")
    I '<3' reputation. If I helped, click the scales. This will be helping an internal departmental competition with co-workers.

    Reputation can be granted through the Scales Icon (for classic layout), or the little Star on the bottom of the post next to the blogging function for the new forum layout.

    If you're not busy, and really feel down on life, read my excel blog which may or may not have contents.

  3. #3
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: IF function to determine if a cell is a %

    You need to test for the the number format unless the values are stored as text. You could use a udf like this:

    Function GetFormat(myRange As Range) As String
       GetFormat = myRange.NumberFormat
    End Function

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

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

    Re: IF function to determine if a cell is a %

    You can also use formula like:

    =IF(LEFT(CELL("format",A1))="P","Percentage","Other")

    where A1 contains the number.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

+ 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.2.0