+ Reply to Thread
Results 1 to 10 of 10

Use colour for specific numbers

  1. #1
    Forum Contributor
    Join Date
    06-24-2012
    Location
    Australia
    MS-Off Ver
    Office365
    Posts
    302

    Use colour for specific numbers

    Hello Expert,
    If I have to use Blue color font for prime numbers in a given range, using Excel 2007 ( without VB) is possible?

    Any suggestion?
    Thanks

  2. #2
    Forum Contributor
    Join Date
    09-11-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2013
    Posts
    103

    Re: Use colour for specific numbers

    you could use conditional format.

    Below is the link to learn more about it.

    http://www.contextures.com/xlCondFormat01.html
    Click * to reward me...
    Thank you...

  3. #3
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Use colour for specific numbers

    Hi Karnik,

    See the attached file :-
    Prime Number.xlsx

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Use colour for specific numbers

    Missed to apply the conditional formatting.. now applied, see attached:-
    Prime Number.xlsx

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

  5. #5
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Use colour for specific numbers

    Here is the best way I have found to do this:

    Insert this Function into a VBA Module:
    Please Login or Register  to view this content.
    Then highlight the entire range of cells and apply conditional formatting using this formula: =IsPrime(A1) where A1 is the first row/column in your selected range.

    - Moo
    Last edited by Moo the Dog; 11-19-2012 at 01:17 AM. Reason: IsPrime Code from Blue Moose Technology

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Use colour for specific numbers

    I don't think so.

    By Prime numbers, do you mean, 1, 3, 5, 7, 11, etc?
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Use colour for specific numbers

    @ dilipandey,

    Nice one. However the first two lines are wrong.

  8. #8
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Use colour for specific numbers

    Actually, Winon, it is correct. 1 is not a prime (according to just about every mathematician, and 2 is a prime.

    - Moo

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Use colour for specific numbers

    @ Moo the Dog,

    Yeah, First cup of Java is only kicking in now!

    Thank you.

    @ dilipandey
    Sorry dilipandey.

    I like your approach with the Helper Column B, and the Format should look like this.
    Attached Files Attached Files

  10. #10
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Use colour for specific numbers

    Thanks Moo for clarifying the point ..

    Thanks to Winon for quick understanding and enhancing the conditional formatting

    Karnik, hope your query is resolved.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

+ 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