| 1. |
Solve : Truncating Numbers in Excel? |
|
Answer» Hi All. I am trying to create a form that records data input from a barcode reader. The problem that I have is that the original number on the barcode label contains 12 digits but I only require the last 6 to be displayed in my form. I have tried to re-configure the reader to truncate the number to 6 digits but this doesn't work so I was wondering if anyone can tell me whether there is a way to do this using Excel or a macro. I am using Excel 2010. Mark, that will work if it is a string. -Barcode readers typically input text into the computer by emulating a keyboard. It will literally type the number digits into the computer when scanned. This would be the only way supported within Excel. -representing BARCODES as numeric types would be INEFFECTIVE as any sort of validation would need to convert it to a string to perform a number of string operations. -Even if the cell type in excel is numeric- which would be the likely default, It doesn't matter what type of data is in the cell. Excel will coerce the data to a text string if necessary. =RIGHT(ATAN(1)*4,7) gives "5358979" for example. -We know the cell type is almost certainly not numeric as a 12-digit numeric value will be shown via scientific notation which is useless as a barcode. You are right. a 12 digit real number would be way beyhound normal usage.Just in case you may have leading or trailing spaces in your barcode input, I would use this: last6 = Right(trim(mybarcode), 6) |
|