Home
%3CLINGO-SUB%20id%3D%22lingo-sub-850068%22%20slang%3D%22en-US%22%3EConditional%20Number%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-850068%22%20slang%3D%22en-US%22%3E%3CH3%20id%3D%22toc-hId-1624460350%22%20id%3D%22toc-hId-1624728563%22%20id%3D%22toc-hId-1624728563%22%20id%3D%22toc-hId-1624728563%22%20id%3D%22toc-hId-1624728563%22%20id%3D%22toc-hId-1624728563%22%3E%3CSPAN%3ELiam%20has%20provided%20financial%20modelling%20services%20and%20training%20to%20clients%20for%20more%20than%20two%20decades.%20A%20senior%20accountant%20and%20professional%20mathematician%2C%20he%20has%20worked%20in%20numerous%20countries%20with%20many%20internationally%20recognised%20clients%2C%20providing%20and%20reviewing%20strategic%20and%20operational%20models%20for%20various%20key%20business%20assignments%3C%2FSPAN%3E.%3C%2FH3%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EGiven%20that%20one%20of%20the%20primary%20purposes%20of%20a%20spreadsheet%20is%20to%20present%20numerical%20data%2C%20it%20is%20important%20how%20such%20information%20is%20presented.%20Cells%20may%20be%20individually%20formatted%20in%20many%2C%20many%20ways%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131354iD46C626A7270EFE6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Image%2001.png%22%20title%3D%22Image%2001.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFormatting%20only%20changes%20the%20appearance%2C%20not%20the%20underlying%20value%2C%20of%20a%20cell.%20For%20example%2C%20if%20cells%20%3CSTRONG%3EA1%20%3C%2FSTRONG%3Eand%20%3CSTRONG%3EB1%3C%2FSTRONG%3E%20had%20the%20number%20%E2%80%981.4%E2%80%99%20typed%20in%20but%20were%20formatted%20to%20zero%20decimal%20places%2C%20then%20if%20cell%20%3CSTRONG%3EC1%20%3D%20A1%20%2B%20B1%3C%2FSTRONG%3E%2C%20you%20would%20truly%20have%201%20%2B%201%20%3D%203%20(well%2C%201.4%20%2B%201.4%20%3D%202.8%20anyway).%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EExcel%20has%20many%20built-in%20number%20formats%20that%20are%20relatively%20easy%20to%20understand%2C%20%3CEM%3Ee.g.%3C%2FEM%3E%20Currency%2C%20Date%2C%20Percentage.%20The%20default%20format%20is%20%E2%80%98General%E2%80%99%20where%20Excel%20will%20endeavour%20to%20provide%20the%20most%20appropriate%20format%20for%20the%20contents.%20For%20example%2C%20typing%20%E2%80%983%203%2F4%E2%80%99%20into%20a%20cell%20will%20result%20in%20Excel%20selecting%20a%20mixed%20format.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EBut%20what%20do%20you%20do%20if%20you%20can%E2%80%99t%20find%20an%20appropriate%20format%3F%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESelecting%20the%20%E2%80%98Custom%E2%80%99%20category%20in%20the%20Number%20tab%20of%20the%20Formal%20Cells%20dialog%20box%20activates%20the%20%E2%80%98Type%3A%E2%80%99%20input%20box%2C%20where%20a%20new%20format%20can%20be%20defined.%20Excel%20allows%20between%20200%20and%20250%20custom%20number%20formats%20in%20a%20particular%20workbook%2C%20depending%20upon%20the%20language%20version%20of%20the%20product%20that%20has%20been%20installed.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20%E2%80%98Type%E2%80%99%20input%20box%20allows%20up%20to%20four%20aspects%20of%20formatting%20to%20be%20specified%20in%20a%20cell.%20These%20aspects%20are%20referred%20to%20as%20sections%20and%20are%20separated%20by%20a%20semi-colon%20(%3B).%20To%20ascertain%20what%20is%20contained%20in%20each%20section%20depends%20on%20the%20total%20number%20of%20sections%20used%2C%20%3CEM%3Eviz.%3C%2FEM%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20484px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131355i0EE82E980E5E9401%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Image%2002.png%22%20title%3D%22Image%2002.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ETo%20the%20uninitiated%2C%20coding%20custom%20number%20formats%20may%20appear%20incomprehensible.%20However%2C%20understanding%20the%20following%20soon%20puts%20things%20into%20perspective%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20584px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131357i3FA0539471D2D1E4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Image%2003.png%22%20title%3D%22Image%2003.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20above%20is%20not%20a%20comprehensive%20list%2C%20but%20it%E2%80%99s%20got%20most%20of%20the%20usual%20suspects.%26nbsp%3B%20To%20d%3C%2FSPAN%3E%3CSPAN%3Eemonstrate%2C%20here%E2%80%99s%20a%20comprehensive%20example%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CSTRONG%3E%3CSPAN%3E%5BBlue%5D%24*%20_(%23%2C%23%230.0%2C_0_)%3B%5BRed%5D%24*%20(%23%2C%23%230.00%2C)%3B%5BColor%207%5D%5C-_._0_0_)%3B%5BCyan%5D%40*.%E2%80%9Dis%20text%E2%80%9D%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20598px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131358iEC44EC97A604E8FA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Image%2004.png%22%20title%3D%22Image%2004.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThis%20format%20has%20all%20four%20sections%2C%20so%20the%20first%20section%2C%20%3CSTRONG%3E%5BBlue%5D%24*%20_(%23%2C%23%230.0%2C_0_)%3C%2FSTRONG%3E%2C%20specifies%20the%20formatting%20for%20positive%20numbers.%20In%20this%20case%2C%20positive%20numbers%20will%20be%20formatted%20blue%20and%20be%20preceded%20with%20a%20%24%20sign.%20Note%20the%20use%20of%20the%20asterisk%20followed%20by%20a%20space%3A%20this%20means%20that%20the%20cell%20width%20will%20be%20%E2%80%98padded%20out%E2%80%99%20with%20spaces%20so%20that%20the%20dollar%20sign%20will%20be%20pushed%20to%20the%20very%20left%20of%20the%20cell%20and%20the%20number%20formatting%20will%20be%20to%20the%20very%20right.%20%3CSTRONG%3E_(%20%3C%2FSTRONG%3Eis%20not%20necessary%2C%20strictly%20speaking%2C%20but%20ensures%20there%20is%20space%20made%20for%20an%20open%20bracket%2C%20even%20though%20there%20is%20no%20such%20character%20shown.%20%3CSTRONG%3E%23%2C%23%230.0%2C%3C%2FSTRONG%3E%20ensures%20positive%20numbers%20contain%20thousand%20separators%20(where%20needed)%20and%20displays%20the%20number%20to%20the%20nearest%200.1%20of%20a%20thousand.%20Two%20commas%20at%20the%20end%20would%20have%20the%20number%20displayed%20to%20the%20nearest%200.1%20of%20a%20million%2C%20and%20so%20on.%20Finally%2C%20the%20%3CSTRONG%3E_0_)%3C%2FSTRONG%3E%20requires%20Excel%20to%20maintain%20enough%20space%20at%20the%20right%20end%20of%20a%20cell%20for%20a%20digit%20(not%20necessarily%20zero%20and%20a%20close%20bracket).%20It%20should%20be%20noted%20that%20a%20separate%20underscore%20is%20required%20for%20each%20character%20that%20is%20to%20be%20allowed%20for.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20second%20section%2C%20%3CSTRONG%3E%5BRed%5D%24*%20(%23%2C%23%230.00%2C)%3C%2FSTRONG%3E%2C%20specifies%20the%20formatting%20for%20negative%20numbers.%20It%20is%20similar%20to%20the%20first%20section%2C%20but%20colors%20the%20number%20red%2C%20reports%20numbers%20to%200.01%20of%20a%20thousand%20and%20encloses%20it%20in%20brackets.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20third%20section%2C%20%3CSTRONG%3E%5BColor%207%5D%5C-_._0_0_)%3C%2FSTRONG%3E%2C%20specifies%20the%20formatting%20for%20zero%20values.%20This%20colors%20zero%20values%20%E2%80%9CColor%207%E2%80%9D%20which%20is%20a%20delightful%20pink%20in%20Excel%E2%80%99s%20standard%20color%20palette.%20I%20am%20a%20great%20believer%20in%20using%20a%20dash%2C%20generated%20by%20using%20%3CSTRONG%3E%5C-%20%3C%2FSTRONG%3Ehere%2C%20to%20denote%20zero%20as%20it%20distinguishes%20a%20zero%20value%20from%20something%20that%20is%20approximately%20zero%2C%20which%20can%20be%20useful%20for%20error%20checking%2C%20etc.%20The%20final%20four%20underscored%20characters%2C%20%3CSTRONG%3E_._0_0_)%3C%2FSTRONG%3E%2C%20ensure%20that%20the%20dash%20will%20line%20up%20with%20the%20units%20value%20of%20a%20positive%20or%20negative%20value.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFinally%2C%20the%20fourth%20section%2C%20%3CSTRONG%3E%5BCyan%5D%40*.%E2%80%9Dis%20text%E2%80%9D%3C%2FSTRONG%3E%2C%20defines%20how%20text%20is%20to%20be%20formatted.%20If%20omitted%2C%20text%20is%20simply%20formatted%20%E2%80%98generally%E2%80%99%2C%20but%20here%20it%20will%20be%20colored%20cyan.%20The%20%3CSTRONG%3E%40%3C%2FSTRONG%3E%20symbol%20specifies%20the%20relative%20location%20of%20the%20text%20within%20the%20cell%20(left-hand%20side%20of%20the%20cell)%2C%20the%20%3CSTRONG%3E*.%3C%2FSTRONG%3E%20will%20%E2%80%98fill%E2%80%99%20the%20cell%20with%20period%20characters%20and%20%3CSTRONG%3E%E2%80%9Cis%20text%E2%80%9D%3C%2FSTRONG%3E%20will%20add%20these%20words%20to%20the%20end%20of%20the%20text%2C%20right-aligned%20(note%20no%20%E2%80%98%26amp%3B%E2%80%99%20concatenation%20is%20required%20since%20these%20words%20appear%20in%20the%20formatting%20only).%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThere%E2%80%99s%20another%20way%20it%20can%20be%20used%20though%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CSTRONG%3E%3CSPAN%3E%5B%26gt%3B%3D1000000%5D%23%2C%23%230%2C%2C%22M%22%3B%5B%26gt%3B%3D1000%5D%23%2C%23%230%2C%22K%22%3B0%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CSTRONG%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20421px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131359iE5B860E9BDEDC012%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Image%2005.png%22%20title%3D%22Image%2005.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20left%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20conditions%20are%20included%20in%20square%20brackets%20such%20that%20if%20the%20condition%20is%20true%2C%20the%20following%20formatting%20will%20be%20applied.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIn%20this%20example%2C%20there%20are%20only%20three%20sections%2C%20so%20text%20will%20be%20formatted%20%E2%80%98generally%E2%80%99.%20The%20first%20section%2C%20%3CSTRONG%3E%5B%26gt%3B%3D1000000%5D%23%2C%23%230%2C%2C%22M%22%3C%2FSTRONG%3E%2C%20will%20format%20all%20numbers%20greater%20than%20or%20equal%20to%20a%20million%20to%20the%20nearest%20million%20and%20add%20an%20%E2%80%9CM%E2%80%9D%20to%20the%20end%20of%20the%20number.%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20second%20section%20will%20only%20be%20considered%20if%20the%20first%20condition%20is%20not%20true%2C%20so%20the%20order%20of%20the%20two%20%E2%80%98conditional%20formats%E2%80%99%20needs%20to%20be%20thought%20through.%20Here%2C%20the%20second%20section%2C%20%3CSTRONG%3E%5B%26gt%3B%3D1000%5D%23%2C%23%230%2C%22K%22%3C%2FSTRONG%3E%2C%20will%20format%20all%20numbers%20greater%20than%20or%20equal%20to%20a%20thousand%20(but%20necessarily%20less%20than%20a%20million)%20to%20the%20nearest%20thousand%20and%20add%20a%20%E2%80%9CK%E2%80%9D%20to%20the%20end%20of%20the%20number.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20third%20and%20final%20section%2C%20%3CSTRONG%3E0%3C%2FSTRONG%3E%2C%20will%20format%20all%20other%20numbers%20(every%20value%20less%20than%201%2C000)%20to%20the%20nearest%20integer%20without%20thousands%20separator(s).%20Pretty%20cool%2C%20eh%3F%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESo%20far%20so%20good%2C%20but%20this%20could%20have%20all%20been%20gleaned%20elsewhere.%20Let%E2%80%99s%20turn%20this%20idea%20up%20to%2011.%20Imagine%20you%20wanted%20to%20format%20a%20cell%20so%20that%20the%20following%20values%20would%20appear%20as%20follows%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20185px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131361iA066ABECFDB3EBD4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Image%2006.png%22%20title%3D%22Image%2006.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20issue%20here%20is%20how%20to%20create%20the%20correct%20formatting%20without%20using%20VBA%20code%20or%20Excel%20formulae%20in%20%3CU%3EONE%3C%2FU%3E%20cell%20so%20that%20if%20any%20of%20the%20above%20values%20in%20the%20left-hand%20column%20are%20entered%20into%20that%20cell%20they%20will%20appear%20as%20they%20are%20displayed%20in%20the%20right-hand%20column.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThere%20are%20too%20many%20examples%20to%20use%20custom%20number%20formatting%20here%20%E2%80%93%20I%20want%20things%20in%20positive%20and%20negative%20millions%20(formatted%20differently)%2C%20positive%20and%20negative%20thousands%20(formatted%20differently)%2C%20positive%20and%20negative%20numbers%20in%20absolute%20terms%20below%201%2C000%2C%20positive%20and%20negative%20percentages%20(formatted%20differently)%2C%20zeroes%20and%20text.%20I%E2%80%99m%20becoming%20exhausted%20just%20typing%20this%20%E2%80%93%20never%20mind%20figuring%20out%20how%20to%20do%20it!%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--927696611%22%20id%3D%22toc-hId--927428398%22%20id%3D%22toc-hId--927428398%22%20id%3D%22toc-hId--927428398%22%20id%3D%22toc-hId--927428398%22%20id%3D%22toc-hId--927428398%22%3E%3CSPAN%3E%3CBR%20%2F%3EConditional%20Formatting%3C%2FSPAN%3E%3C%2FH3%3E%0A%3CP%3E%3CSPAN%3EConditional%20formatting%20was%20completely%20revamped%20and%20reinvented%20with%20the%20introduction%20of%20Excel%202007.%20You%20can%20now%20find%20it%20in%20the%20%E2%80%98Styles%E2%80%99%20group%20of%20the%20%E2%80%98Home%E2%80%99%20tab%20%E2%80%93%20or%20using%20the%20keyboard%20shortcut%20%3CSTRONG%3EALT%20%2B%20O%20%2B%20D%3C%2FSTRONG%3E%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20196px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131363i790311E2F2AC027E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Image%2007.png%22%20title%3D%22Image%2007.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EI%20can%20use%20%E2%80%98New%20Rule%E2%80%A6%E2%80%99%20to%20exploit%20a%20loophole%20in%20the%20restrictive%20number%20of%20conditions%20custom%20number%20formatting%20appears%20to%20allow.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EUsing%20custom%20number%20formatting%20and%20conditional%20formatting%20combined%20the%20requirement%20is%20fairly%20straightforward.%20My%20suggested%20solution%20would%20be%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CSPAN%3EConstruct%20the%20underlying%20number%20formatting%20first.%26nbsp%3B%20Personally%2C%20I%20would%20use%20custom%20number%20formatting%20so%20that%20all%20positive%20and%20negative%20numbers%20appeared%20as%20percentages%2C%20zero%20as%20a%20hyphen%20and%20text%20as%20displayed%20above%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3E%5BBlue%5D_(%23%2C%23%230.00%25_)%3B%5BRed%5D(%23%2C%23%230.00%25)%3B-%3B%40%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CSPAN%3ENext%2C%20I%20would%20apply%20conditional%20formatting%20number%20formatting%20where%20the%20cell%20value%20is%20greater%20than%20one%20so%20that%20numbers%20greater%20than%20a%20million%20could%20be%20displayed%20to%20the%20nearest%200.1m%2C%20numbers%20less%20than%20a%20million%20but%20greater%20than%20or%20equal%20to%201%2C000%20could%20be%20displayed%20to%20the%20nearest%200.00k%20and%20numbers%20lower%20than%201%2C000%20(but%20necessarily%20greater%20than%20one)%20could%20be%20displayed%20as%20integers%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3E%5BBlue%5D%5B%26gt%3B%3D1000000%5D%23%2C%23%230.0%2C%2C%22m%22%3B%5BBlue%5D%5B%26gt%3B%3D1000%5D%23%2C%23%230.00%2C%22k%22%3B%5BBlue%5D0%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CSPAN%3EFinally%2C%20I%20would%20apply%20a%20second%20set%20of%20conditional%20formatting%20where%20the%20cell%20value%20is%20less%20than%20-1%20as%20required%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3E%5BRed%5D%5B%26lt%3B%3D-1000000%5D(%23%2C%23%230%2C%2C%22m%22)%3B%5BRed%5D%5B%26lt%3B%3D-1000%5D(%23%2C%23%230%2C%22k%22)%3B%5BRed%5D0%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%3EHere%E2%80%99s%20an%20illustration%20of%20that%20final%20formatting%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131364iD9E989C26A65F04C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Image%2008.png%22%20title%3D%22Image%2008.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIn%20this%20above%20illustration%2C%20I%20have%20selected%20conditional%20formatting%20to%20occur%20if%20the%20value%20in%20the%20cell%20is%20less%20than%20-1.%20Pressing%20the%20%E2%80%98Format%E2%80%A6%E2%80%99%20button%20then%20allows%20the%20user%20to%20select%20how%20the%20number%20formatting%20might%20appear.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESince%20many%2C%20many%20conditional%20formats%20may%20be%20applied%20to%20one%20cell%20in%20Excel%2C%20you%20can%20soon%20apply%20significantly%20more%20than%20four%20formats%20to%20any%20cell(s)%20in%20Excel.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3E%3CSPAN%3EWord%20to%20the%20Wise%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EAlthough%20I%20have%20explained%20you%20can%20circumvent%20the%20apparent%20limitations%20in%20number%20formatting%20using%20conditional%20formatting%2C%20applying%20too%20many%20unnecessary%20conditional%20formats%20can%20cause%20Excel%20to%20misbehave%20with%20cells%20not%20updating%20as%20intended%20and%20other%20cells%20(not%20formatted)%20changing%20as%20well.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFurther%2C%20using%20lots%20of%20custom%20number%20formats%20in%20a%20single%20workbook%20uses%20considerable%20memory%20and%20can%20slow%20down%20the%20calculation%20time%20of%20an%20Excel%20file%20unnecessarily.%20Many%20of%20these%20formats%20are%20created%20accidentally.%20Each%20time%20a%20custom%20number%20format%20is%20edited%2C%20it%20will%20generate%20an%20additional%20listing%20for%20Custom%20Category%20Types.%20Any%20custom%20formats%20created%20inadvertently%20in%20this%20manner%20(that%20are%20not%20being%20used%20in%20the%20file)%20should%20be%20deleted%3B%20good%20housekeeping%20is%20essential.%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F20141%22%20target%3D%22_blank%22%3E%40Liam%20Bastick%3C%2FA%3E%26nbsp%3Bis%20an%20Excel%20MVP%2C%20originally%20from%20the%20UK%2C%20but%20now%20based%20in%20Australia.%20He%20heads%20the%20global%20consulting%20%2F%20training%20firm%20SumProduct%20(sumproduct.com).%20You%20can%20contact%20him%20at%20%3CA%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23146cac%3B%20text-decoration%3A%20underline%3B%22%20href%3D%22mailto%3Aliam.bastick%40sumproduct.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eliam.bastick%40sumproduct.com%3C%2FA%3E.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-850068%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20to%20get%20smarter%20with%20number%20formatting%20using%20conditional%20formatting%20in%20tandem.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-850068%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBlog%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-863078%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Number%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-863078%22%20slang%3D%22en-US%22%3E%3CP%3EConditional%20formatting%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-868125%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Number%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-868125%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20deciphering%20the%20formatting%20codes!!%20Finally%20got%20it%20after%2010%20years%20of%20using.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-873081%22%20slang%3D%22es-ES%22%3ERe%3A%20Conditional%20Number%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-873081%22%20slang%3D%22es-ES%22%3E%3CP%3EHi%2C%20Liam%20%26amp%3B%20everyone%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20question%20concerning%20conditionnal%20formatting%3B%20I'd%20like%20that%20the%20text%20in%20a%20certain%20cell%20turns%20to%20another%20color%20if%20%26lt%3B%3D0%2C%20it%3D%22%22%20is%3D%22%22%20the%3D%22%22%20same%3D%22%22%20for%3D%22%22%26gt%3B%20%20%3CBR%20%2F%3Ethe%20value%20of%20another%20cell%20is%20%26gt%3B0%20-%20or%20if%20it%20is%20Probably%20it%20is%20an%20easy%20question%20but%20I%20am%20far%20than%20expert...%20and%20I%20need%20it...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20so%20much%20in%20advance%2C%20best%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Esergio%3C%2FP%3E%3C%2FLINGO-BODY%3E

Liam has provided financial modelling services and training to clients for more than two decades. A senior accountant and professional mathematician, he has worked in numerous countries with many internationally recognised clients, providing and reviewing strategic and operational models for various key business assignments.

 

Given that one of the primary purposes of a spreadsheet is to present numerical data, it is important how such information is presented. Cells may be individually formatted in many, many ways:

 

Image 01.png

 

Formatting only changes the appearance, not the underlying value, of a cell. For example, if cells A1 and B1 had the number ‘1.4’ typed in but were formatted to zero decimal places, then if cell C1 = A1 + B1, you would truly have 1 + 1 = 3 (well, 1.4 + 1.4 = 2.8 anyway).

 

Excel has many built-in number formats that are relatively easy to understand, e.g. Currency, Date, Percentage. The default format is ‘General’ where Excel will endeavour to provide the most appropriate format for the contents. For example, typing ‘3 3/4’ into a cell will result in Excel selecting a mixed format.

 

But what do you do if you can’t find an appropriate format?

 

Selecting the ‘Custom’ category in the Number tab of the Formal Cells dialog box activates the ‘Type:’ input box, where a new format can be defined. Excel allows between 200 and 250 custom number formats in a particular workbook, depending upon the language version of the product that has been installed.

 

The ‘Type’ input box allows up to four aspects of formatting to be specified in a cell. These aspects are referred to as sections and are separated by a semi-colon (;). To ascertain what is contained in each section depends on the total number of sections used, viz.

 

Image 02.png

 

To the uninitiated, coding custom number formats may appear incomprehensible. However, understanding the following soon puts things into perspective:

 

Image 03.png

 

The above is not a comprehensive list, but it’s got most of the usual suspects.  To demonstrate, here’s a comprehensive example:

[Blue]$* _(#,##0.0,_0_);[Red]$* (#,##0.00,);[Color 7]\-_._0_0_);[Cyan]@*.”is text”

 

Image 04.png

 

This format has all four sections, so the first section, [Blue]$* _(#,##0.0,_0_), specifies the formatting for positive numbers. In this case, positive numbers will be formatted blue and be preceded with a $ sign. Note the use of the asterisk followed by a space: this means that the cell width will be ‘padded out’ with spaces so that the dollar sign will be pushed to the very left of the cell and the number formatting will be to the very right. _( is not necessary, strictly speaking, but ensures there is space made for an open bracket, even though there is no such character shown. #,##0.0, ensures positive numbers contain thousand separators (where needed) and displays the number to the nearest 0.1 of a thousand. Two commas at the end would have the number displayed to the nearest 0.1 of a million, and so on. Finally, the _0_) requires Excel to maintain enough space at the right end of a cell for a digit (not necessarily zero and a close bracket). It should be noted that a separate underscore is required for each character that is to be allowed for.

 

The second section, [Red]$* (#,##0.00,), specifies the formatting for negative numbers. It is similar to the first section, but colors the number red, reports numbers to 0.01 of a thousand and encloses it in brackets.

 

The third section, [Color 7]\-_._0_0_), specifies the formatting for zero values. This colors zero values “Color 7” which is a delightful pink in Excel’s standard color palette. I am a great believer in using a dash, generated by using \- here, to denote zero as it distinguishes a zero value from something that is approximately zero, which can be useful for error checking, etc. The final four underscored characters, _._0_0_), ensure that the dash will line up with the units value of a positive or negative value.

 

Finally, the fourth section, [Cyan]@*.”is text”, defines how text is to be formatted. If omitted, text is simply formatted ‘generally’, but here it will be colored cyan. The @ symbol specifies the relative location of the text within the cell (left-hand side of the cell), the *. will ‘fill’ the cell with period characters and “is text” will add these words to the end of the text, right-aligned (note no ‘&’ concatenation is required since these words appear in the formatting only).

There’s another way it can be used though:

 

[>=1000000]#,##0,,"M";[>=1000]#,##0,"K";0

 

Image 05.png

 

 

The conditions are included in square brackets such that if the condition is true, the following formatting will be applied.

 

In this example, there are only three sections, so text will be formatted ‘generally’. The first section, [>=1000000]#,##0,,"M", will format all numbers greater than or equal to a million to the nearest million and add an “M” to the end of the number.

 

The second section will only be considered if the first condition is not true, so the order of the two ‘conditional formats’ needs to be thought through. Here, the second section, [>=1000]#,##0,"K", will format all numbers greater than or equal to a thousand (but necessarily less than a million) to the nearest thousand and add a “K” to the end of the number.

 

The third and final section, 0, will format all other numbers (every value less than 1,000) to the nearest integer without thousands separator(s). Pretty cool, eh?

 

So far so good, but this could have all been gleaned elsewhere. Let’s turn this idea up to 11. Imagine you wanted to format a cell so that the following values would appear as follows:

 

Image 06.png

 

The issue here is how to create the correct formatting without using VBA code or Excel formulae in ONE cell so that if any of the above values in the left-hand column are entered into that cell they will appear as they are displayed in the right-hand column.

 

There are too many examples to use custom number formatting here – I want things in positive and negative millions (formatted differently), positive and negative thousands (formatted differently), positive and negative numbers in absolute terms below 1,000, positive and negative percentages (formatted differently), zeroes and text. I’m becoming exhausted just typing this – never mind figuring out how to do it!


Conditional Formatting

Conditional formatting was completely revamped and reinvented with the introduction of Excel 2007. You can now find it in the ‘Styles’ group of the ‘Home’ tab – or using the keyboard shortcut ALT + O + D:

 

Image 07.png

 

I can use ‘New Rule…’ to exploit a loophole in the restrictive number of conditions custom number formatting appears to allow.

Using custom number formatting and conditional formatting combined the requirement is fairly straightforward. My suggested solution would be:

 

  • Construct the underlying number formatting first.  Personally, I would use custom number formatting so that all positive and negative numbers appeared as percentages, zero as a hyphen and text as displayed above:

    [Blue]_(#,##0.00%_);[Red](#,##0.00%);-;@
  • Next, I would apply conditional formatting number formatting where the cell value is greater than one so that numbers greater than a million could be displayed to the nearest 0.1m, numbers less than a million but greater than or equal to 1,000 could be displayed to the nearest 0.00k and numbers lower than 1,000 (but necessarily greater than one) could be displayed as integers:

    [Blue][>=1000000]#,##0.0,,"m";[Blue][>=1000]#,##0.00,"k";[Blue]0

  • Finally, I would apply a second set of conditional formatting where the cell value is less than -1 as required:

    [Red][<=-1000000](#,##0,,"m");[Red][<=-1000](#,##0,"k");[Red]0

Here’s an illustration of that final formatting:

 

Image 08.png

 

In this above illustration, I have selected conditional formatting to occur if the value in the cell is less than -1. Pressing the ‘Format…’ button then allows the user to select how the number formatting might appear.

 

Since many, many conditional formats may be applied to one cell in Excel, you can soon apply significantly more than four formats to any cell(s) in Excel. 

 

 

Word to the Wise

Although I have explained you can circumvent the apparent limitations in number formatting using conditional formatting, applying too many unnecessary conditional formats can cause Excel to misbehave with cells not updating as intended and other cells (not formatted) changing as well.

 

Further, using lots of custom number formats in a single workbook uses considerable memory and can slow down the calculation time of an Excel file unnecessarily. Many of these formats are created accidentally. Each time a custom number format is edited, it will generate an additional listing for Custom Category Types. Any custom formats created inadvertently in this manner (that are not being used in the file) should be deleted; good housekeeping is essential.

 

@Liam Bastick is an Excel MVP, originally from the UK, but now based in Australia. He heads the global consulting / training firm SumProduct (sumproduct.com). You can contact him at liam.bastick@sumproduct.com.

 

5 Comments
Established Member

Conditional formatting

Occasional Visitor

Thank you for deciphering the formatting codes!! Finally got it after 10 years of using.

Occasional Visitor

Hi, Liam & everyone,

 

I have a question concerning conditionnal formatting; I´d like that the text in a certain cell turns to another color if the value of another cell is >0 - or if it is <=0, it is the same for me).
Probably it is an easy question but I am far than expert...and I need it...

 

Thanks so much in advance, best,

 

sergio

Occasional Visitor

Thank you, Liam.

I'd love to see similar formatting capabilities as in the Excel Chart Axis, where you can format in Hundreds, Thousands, 10,000 , … 

Business Case: Often, I need to display percentages without the % 'symbol' and in hundredths (1/100s), eg: show 0.63 as 63 and not 63%.  A workaround is to multiply a cell expression by 100 and display it as a regular number and not a percentage, however any computation using this cell would need to be adjusted. 

Note that it is possible to display a number in thousands, millions or multiples of x1,000 by adding a comma to the custom format:  

           #,##0    can be changed to     #,##0,  for thousands    and    #,##0,,    for millions

Yet, no option for Hundreds or 1/100s.

(By the way, same thing for PowerBI, a percent without the % symbol would be great)

To @slaspalas: This is a job for conditional formatting.  Click on Home -> Conditional Formatting -> New Rule... (ALT + O + D), then click on the 'New Rule...' button in the top left-hand corner of the resulting 'Conditional Formatting Rules Manager' dialog.  In the next dialog, select the final Rule Type ('Use a formula to determine which cells to format'), then write the formula you require in the 'Format values when this formula is true:' dialog (e.g. =A1>0) and then click on the 'Format...' button to modify as you see fit.  Once happy, keep clicking 'OK' and 'Apply' buttons until you are back in Excel.  Done!