+ Reply to Thread
Results 1 to 5 of 5

if statement based on custom number format of a cell

  1. #1
    Registered User
    Join Date
    11-15-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    97

    if statement based on custom number format of a cell

    Hi,

    My accounting package exports data into excel. The numbers are all formatted either as ""0.00" Cr" or ""0.00" Dr" (accounting equivalent to plus and minus).

    I am trying to format reports in Excel using the data exported by the accounting package. If the cell number format is ""0.00" Cr" in the exported data, I want the number to be displayed as (100.00) in my report. Similarly, if the cell number format is ""0.00" Dr" in the exported data, I want the number to be displayed as 100.00.

    I have been trying to find a way of using an IF statement to achieve this - IF("Custom Number Format of Cell A7" = ""0.00" Cr", -A7, A7), but not able to get the result.

    I would be very grateful if someone can guide me on how this can be achieved.

  2. #2
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: if statement based on custom number format of a cell

    Suggest you post a sample workbook with some typical data.

  3. #3
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    186

    Re: if statement based on custom number format of a cell

    The CELL function can return a code that corresponds to the number format of the cell...
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Maybe you could use that in your logic argument if the cells are actually formatted that way, or perhaps in conjunction with conditional formatting.

    If the data is just printed that way and the cells are still formatted as general or text or whatever, then you maybe better off extracting the figure more along the lines of...

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Or without the "" " " speech marks...

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I don't know for sure without seeing it, I suspect I could be more helpful if you posted an example.

  4. #4
    Registered User
    Join Date
    11-15-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    97

    Re: if statement based on custom number format of a cell

    Hi,

    My accounting package exports data into excel. The numbers are all formatted either as ""0.00" Cr" or ""0.00" Dr" (accounting equivalent to plus and minus).

    I am trying to format reports in Excel using the data exported by the accounting package. If the cell number format is ""0.00" Cr" in the exported data,
    I want the number to be displayed as (100.00) in my report. Similarly, if the cell number format is ""0.00" Dr" in the exported data, I want the number
    to be displayed as 100.00.

    I have been trying to find a way of using an IF statement to achieve this, for example IF("Custom Number Format of Cell A7" = ""0.00" Cr", -A7, A7), but not able to
    get the result.

    I have attached a sample workbook that will provide more clarity.

    I would be very grateful if someone can guide me on how I can be achieved the desired result. Thanks in advance to everyone for your efforts in helping me

    Anandvh
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,508

    Re: if statement based on custom number format of a cell

    Sample VBA


    Please Login or Register  to view this content.
    Named ranges CR and DR formatted as your input.

    Macro changes format.
    Attached Files Attached Files

+ 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. VBA for if statement based on number format selection
    By Pilot5000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-02-2015, 01:24 PM
  2. Replies: 3
    Last Post: 04-27-2015, 09:41 AM
  3. Add Cell Custom Format after entered number
    By cosmarchy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-12-2013, 10:24 AM
  4. Custom Number Cell Format
    By Big Rick in forum Excel General
    Replies: 5
    Last Post: 05-02-2012, 04:07 PM
  5. About Custom Format Cell Number
    By BlastRanger in forum Excel General
    Replies: 2
    Last Post: 09-08-2010, 02:55 AM
  6. Format a cell with a custom number format
    By Armor in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-29-2006, 07:30 PM
  7. Format Cell (Number Custom)
    By barryderay in forum Excel General
    Replies: 1
    Last Post: 04-27-2005, 08:06 PM

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