<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttp://mvark.blogspot.com/\x26vt\x3d-5147029996388199615', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

Search from over a hundred HOW TO articles, Tips and Tricks


HOW TO prefix zeroes before a variable length number in Excel

Excel usually eats up any zeroes prefixed to a number that you type. So what if you explicitly needed them?

For a fixed length number, you have to use the option Format Cells after right-clicking the cell or range that you want to impose a number format upon. In the dialog box that opens go to to the Number tab, pick the Custom option & specify the number format. If you wanted the number 8217 or any 4 digit number to have 5 zeroes prefixed before it, you would have to specify the number format as 000000000 so that it shows up as 000008217. The trick here is to know what the meta-characters in the format mean.

Browsing through the generally good documentation by F1-ing, I did not find a format to handle variable length numbers for the scenario just described. I got a solution from a MS Knowledgebase article, which is to use the format "00000"#. The double quotes in the number format helps us prefix the desired number of zeroes before a variable length number.


Related:
Excel Tips & Tricks

Labels:

Tweet this | Google+ it | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »

»

Post a Comment