+ Reply to Thread
Results 1 to 6 of 6

Find Cells Containing a Specific Number Format

  1. #1
    Registered User
    Join Date
    12-12-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    4

    Find Cells Containing a Specific Number Format

    I am trying to write code that would find cells containing numbers formatted a certain way and then do some operations on those numbers.

    The If statement below is able to identify some formatting, but I can't get it to identify a number with two decimal places.

    I would like to change numbers such as 17.55 and ignore whole numbers, such as 17.

    I tried both If cell.NumberFormat = "#.##" and If cell.NumberFormat = "0.00" but neither of those works.

    When I run If cell.NumberFormat = "0.00%" it is able to find cells containing percentages with that format.

    How can I change the If statement to identify only numbers with two decimal places?


    Please Login or Register  to view this content.

  2. #2
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Find Cells Containing a Specific Number Format

    Hi alpinegroove,

    I have checked your code, it works well. Use the below code,

    Please Login or Register  to view this content.
    and make sure that selection that you make in NUMBER FORMAT.



    Regards,
    Paresh J
    Click on "* Add Reputation" as a way to say thanks

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find Cells Containing a Specific Number Format

    Maye try this...

    If cell.Value <> Int(cell.Value) Then
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    12-12-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Find Cells Containing a Specific Number Format

    Thank you. It looks like If cell.NumberFormat only works when the selection is already formatted as a number. It does not work when it is set to General.

    However, If cell.Value <> Int(cell.Value) does work when it is set to General. The problem now is that I get an error since some of my cells have text in them.

    Any way around that?

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find Cells Containing a Specific Number Format

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-12-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Find Cells Containing a Specific Number Format

    Perfect, thanks!

    Quote Originally Posted by AlphaFrog View Post
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How can I find and format specific cells automatically in Excel?
    By Amy in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  2. [SOLVED] How can I find and format specific cells automatically in Excel?
    By Amy in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 PM
  3. [SOLVED] How can I find and format specific cells automatically in Excel?
    By Gary's Student in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 02:05 PM
  4. How can I find and format specific cells automatically in Excel?
    By Gary's Student in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  5. How can I find and format specific cells automatically in Excel?
    By Amy in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM

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