ExcelTip.com
ExcelTip.com
Account Icon Account Icon Account Icon
Google Exceltip.com
JOIN OUR NEWSLETTER
  and receive for joining:
Free eBook Learn More!
Free Excel ADD-IN
Free Weekly Excel Tip
4 e-books in cd-rom
F1 Formulas & Functions
F1 Formulas & Functions
F1 EXCEL
F1 eBook (Spanish)
F1 EXCEL
Financial Statements.xls
 

» Separating a Number Into Digits
Problem:

Separating the number in A2 into digits, so that each of cells B2:G2 will contain one digit.

Solution:

Using the MID and COLUMN functions, as follows:
=MID($A2,COLUMN()-1,1)


Screenshot // Separating a Number Into Digits

Separating a Number Into Digits
Rate this tip
12 34 5
  RATING: 2.94
  VIEWS: 22877

READER COMMENTS (view all comments)


Does not work for me
DougStroud wrote on May 24, 2006 09:28 EST
I am only able to extract one digit from the number.

Hmmmm?

janet21 wrote on May 24, 2006 10:02 EST
Had the same problem. Just copy with a little trial and error found you copy the formula into the relevant cells and it works
Why "-1" in Formula?
cccgsmith wrote on May 24, 2006 10:15 EST
It worked, but I had to delete the "-1" in the formula for the first digit to appear properly in the same column as the original number.
Why would I use this?
rasmaniac wrote on May 24, 2006 10:30 EST
I can't think of any use for this tip. Any ideas?
This is cool
Rajiv wrote on December 31, 1969 19:00 EST
Aha this sounds cool. but would it not be great to have tips with possible applications? I am thinking hard, where to use this tip?
I wish I had known
MATECH wrote on December 31, 1969 19:00 EST
I wish I had known this. I'm converting data for our new HR and Finance Software and some of the data needed to be separated based on the old method of storage.
This is cool
Rajiv wrote on December 31, 1969 19:00 EST
Aha this sounds cool. but would it not be great to have tips with possible applications? I am thinking hard, where to use this tip?
USAGE
atesumpu wrote on December 31, 1969 19:00 EST
One could modify this formula for parsing .DBF or .CSV files.

janet21 wrote on May 24, 2006 11:39 EST
I suppose that if someone has a lot of single figures across the columns at least it would only be one column to check back! other than that not sure.

Conor wrote on May 24, 2006 15:28 EST
This tip only works if your text is in column A. Otherwise you need to revise the formula to indicate the column your text is actually in.

The "column()-1" section says take the column number the formula is in (Column B = 2; Column C = 3, etc.), subtract 1 from that number and give me that character position in the text string.

So, if 9876 is in column A, the formula in column B will give the first character or "9"; the formula in column C will give the second character or "8", etc.:)
Good
kannan wrote on December 31, 1969 19:00 EST
This is really good.But if you want to use it in different column this will not work.Correct?.Because column() function will give the value of correct column only.
Usage
Ashish wrote on December 31, 1969 19:00 EST
Am not able to figure out where to use it?
May be if we have to design a Digit to word converter it may be useful.
Usage
Ashish wrote on December 31, 1969 19:00 EST
Am not able to figure out where to use it?
May be if we have to design a Digit to word converter it may be useful.
There is use
GReeN78 wrote on December 31, 1969 19:00 EST
Hi, I'm working in a bank and we have to make electronic payment orders, where every digit has to be in separate cell but it has to be written in one cell to be more comfortable for the user. This method is good, but not enough according to me, because if you have an amount, lets say EUR 265.40 it will not pick up the last digit which is "zero" and Excel skips it. In column "G" with this formula you will get "" instead of 0. In order to avoid this i'm using this with combination with IF ... ROUNDDOWN .. is equal to A2 in order to extract the zero at the end and populate it in the proper cell.
Separating a number into digits
Ghassan Mhanna wrote on December 31, 1969 19:00 EST
it doesn't work, the formula should be as folows:
=MID($A2,COLUMN()-COLUMN($A2),1)
And now it can be draged in the right direction to other cells
Extrapolating numbers into single digits per columm
Sasha Frugone wrote on July 06, 2006 17:00 EST
I use a similar function in a macro that converts dollars & cents into words
Separating Numbers Into Digits per column or rows
Sfrugone wrote on December 31, 1969 19:00 EST
What I use this type of function for is to convert dollars into written words.
Correct usage
Sankara Courtallam R wrote on December 31, 1969 19:00 EST
The formula worked with slight change,
"=mid($A2,column(),1)"
Close but no cigar
ken@kiacomm.us wrote on December 31, 1969 19:00 EST
I have need for this type of formula, but I have the following combination of letters and numbers to deal with.

HBFO(156)(156)(48)(36)[6]. I would like to extract the numbers between the "( and ")"; "[" and "]", and separate them into columns. like this:
A B C D E F G
156 156 48 36 5

Your help would be greatly appreciated
-ken

ado1963 wrote on August 18, 2006 04:45 EST
[I]Ken Wrote:
I have need for this type of formula, but I have the following combination of letters and numbers to deal with.

HBFO(156)(156)(48)(36)[6]. I would like to extract the numbers between the "( and ")"; "[" and "]", and separate them into columns. like this:
A B C D E F G
156 156 48 36 5 [/I]

If the format of the string is constant, ie always 4 letters, then 3 bracketed numbers, a further 3 bracketed numbers etc., the Text to columns wizard with fixed with on the data menu could prove useful

kbeard wrote on August 21, 2006 08:31 EST
[QUOTE=ken@kiacomm.us]I have need for this type of formula, but I have the following combination of letters and numbers to deal with.

HBFO(156)(156)(48)(36)[6]. I would like to extract the numbers between the "( and ")"; "[" and "]", and separate them into columns. like this:
A B C D E F G
156 156 48 36 5

Your help would be greatly appreciated
-ken[/QUOTE]

Ken,
This may be what you are looking for. Or at least it will point you in the right direction. You can use numbers or letters in this type Syntax. You can find help on this matter by pressing F1 in Excel.
sounds good
manoj wrote on December 31, 1969 19:00 EST
It worked, but I am not getting the first digit to appear properly in the same column as the original number. i.e.

if i have to seperate 243256 using formula

first digit is missing & result in 4 3 2 5 6

missing 2

??????????


It doesn't work with very large numbers
Ilikepi wrote on May 18, 2007 22:42 EST
The program is very useful to me, but unfortunatly I have incountered a problem (I understand there are many people have found but this is the only one I have incountered) it doesn't wok with very large numbers. like if you entered a very large number, say a pi to 100 decimal points, instead of putting the large number in the cell it puts a rounded scientific notation, the program mirrors what's in the cell not the text bar. So if you were to do this you would get a streched out version of sciefific notation, not the number. I don't know ow to fix this and it would be greatly appreciated if someone could help fix the problem (if it's fixable).
Separating a Number Into Digits
myBoo wrote on July 20, 2007 12:01 EST
It seems that MID() and COLUMN() can give varying results.

Example: Cell A2 = 1234567890

If cell A5 contains =Mid($A2,Column(),1) .... it will result in 1
If cell B5 contains =Mid($A2,Column(),1) .... it will result in 2
But,
If cell B5 contains =Mid($A2,Column(A2),1) .... it will result in 1
If cell B5 contains =Mid($A2,Column(A2),2) .... it will result in 12

=Column(), by itself, returns the reference to the column the formula is entered in. So, if B5 contains =Mid($A2,Column()-1,1) ... it will result in 1 because Column B is the 2nd column (2-1) = 1.
=Column(A2) would result in 1 as you are referencing cell A2 and column A is the 1st column.

This tells me the originator of the Tip did not need to include Column()-1,1 in their formula.... Column(),1 would work.
You can test this out by entering =Column()-1 in Cell F2. Column F is the sixth column in a spreadsheet. Your results will be 5.

I tested all of the above on Excel 2000. Results may vary on other versions.

To make this even more confusing...

If cell B5 contains =Mid($A2,Column(A2)*4,2) ... it will result in 45. The *4 tells Excel which digit to start with in the cell A2 and the ,2 tells Excel to return 2 digits.

Bottom Line: You need to understand =Mid() and =Column() in order to make this work correctly.



REGISTERED USERS - Click here to post comments


GUESTS (Click here to register)
Name
Comment Title
Comments

Microsoft Excel 2002 Simply Visual

Marketing Plans

Microsoft Office XP Step-By-Step (With CD-ROM)

Special Edition Using Microsoft Excel 2002

Analysis of Financial Statements

Retire Young, Retire Rich

RELATED MICROSOFT EXCEL TIPS


Convert PDF Files to Excel






Excel VBA books
Accounting books
Business Plans
MS Office books
Taxes books

VIEW ALL BOOKS


  Advertise With Us                               

Tips

Add-In in VBA | Applications - Word, Outlook in VBA | Array Formulas | Cells, Ranges, Rows, and Columns in VBA | Counting | Custom Functions | Custom Functions in VBA | Database Formulas | Database in VBA | Date & Time Formulas | Date & Time in VBA | Events in VBA | Excel 2003 | Excel Chart | Excel Consolidating | Excel Counting | Excel Custom Functions using VBA | Excel Customizing | Excel Data | Excel Dates | Excel Editing | Excel Files | Excel Filter | Excel Format | Excel Formula | Excel General | Excel Grouping and Outlining | Excel Importing Text Files | Excel Information | Excel Keyboard Shortcuts | Excel Loan Formulas | Excel Macros - VBA | Excel Pivot Tables | Excel Printing | Excel Range Name | Excel Security - Protection | Excel Sorting | Excel Style | Excel Subtotals | Excel Summing | Excel Text | Excel Time | Excel Tools | Excel Worksheet, Workbook | Files, Workbook, and Worksheets in VBA | Financial Formulas | Formating in VBA | General Topics in VBA | Import and Export in VBA | Information Formulas | Keyboard & Other Shortcuts in VBA | Keyboard Formula Shortcuts | Links between Worksheet and Workbooks | Links in VBA | Logical Formulas | Lookup Formulas | Mail - Send and Receive in VBA | Menus, Toolbars, Status bar in VBA | Modules, Class Modules in VBA | Other Q&A Formulas | Printing in VBA | Protecting in VBA | Summing | Text Formulas | User Forms, Input boxes in VBA | Using Loops | Working with Formulas |

Tips by Version

Microsoft Excel 97 | Microsoft Excel 2000 | Microsoft Excel 2002 | All Microsoft Excel Versions | New in Excel 2002 | New in Excel 2003 - Office 11

Website

Home | Tip of Hour | Recommended Tips | Most Viewed Tips | Tips by Version | Submit a Tip | My Tips
Microsoft Excel Tutorials | Excel Links | Write for Us | About Us | Search Results | Tip Archives | Excel Forum | Excel Forum Archives

Excel Book

Excel 97 Book | Excel 2000 Book | Excel 2002 Book | Excel XP Book | Book Store

Terms and Conditions of use
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Copyright © 2003 ExcelTip.com
Microsoft, Microsoft Excel is a U.S. registered trademark of Microsoft Corporation
Site Developed By: Varien