473,413 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Need help padding numbers

69
Hello all.

I have a problem in an Excel spreadsheet. I have a column with numbers in it where I need to change the value to conform to a certain format.

For example I may have a set of numbers that look like this in the column:

12345
123456
1234567
12345678

I need them all to be changed to conform to this format:

XXXXXXXX-000

with leading zeros to fill in the gaps. So the above numbers would be converted to:

00012345-000
00123456-000
01234567-000
12345678-000

I would like to create the code in excel as a macro and attach it to a button to either fix all numbers in the column or fix one at a time based on active cell.

Any help will be greatly appreciated.

Thanks,
narpet
Dec 14 '06 #1
4 2552
narpet
69
Forgot to add that I may have a number that is already formatted correctly, like:

00123456-000

So I would have to add to the code to not change that number....



Hello all.

I have a problem in an Excel spreadsheet. I have a column with numbers in it where I need to change the value to conform to a certain format.

For example I may have a set of numbers that look like this in the column:

12345
123456
1234567
12345678

I need them all to be changed to conform to this format:

XXXXXXXX-000

with leading zeros to fill in the gaps. So the above numbers would be converted to:

00012345-000
00123456-000
01234567-000
12345678-000

I would like to create the code in excel as a macro and attach it to a button to either fix all numbers in the column or fix one at a time based on active cell.

Any help will be greatly appreciated.

Thanks,
narpet
Dec 14 '06 #2
narpet
69
Never mind... I figured it out.

Thanks,
narpet
Dec 14 '06 #3
Killer42
8,435 Expert 8TB
Never mind... I figured it out.
I hope you're doing it by changing just the display format, and not the value?
Dec 15 '06 #4
narpet
69
Nope... it was already configured to display the way I wanted. The problem was that this information is sent to the state, and they will only take it if the actual data is formatted as I described, and it must be sent to them in a text file.

So I wrote a macro that changes the data to look the way the state wants it. Works perfect.

Thanks,
narpet
Dec 15 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ethan | last post by:
I'm trying to set up a page with a header and 2 columns. I would like to use <div>s rather than tables. The page is here... http://64.142.13.246/style_testing_site/style_model2.htm In both IE...
7
by: jmm-list-gn | last post by:
Hello, <http://www.asaom.edu> There are some curious spacing issues with the top bar (gray) and the main navigation bar. The most significant is how the nav bar looks in Opera v6 (win2k): the...
7
by: Astra | last post by:
Hi All Can you please help me with a few queries on adding a header line and padding rows out. I apologise profusely for not providing the DDL for this, but I don't have it. All I have is...
8
by: stefano.troiani | last post by:
I have some images with link in a row inside a <p> and I gave them a left padding just to be sure they have some space between them. It looks perfectly in FF, IE 6 and IE 5.5 but, in IE 5.1 it...
2
by: dvomsaal | last post by:
I seem to remember there is a way to modify an element based on what it is next to, but I can't seem to locate it. Here's my scenario: We have some pages that are built dynamically and present...
2
by: narpet | last post by:
Hello all. I posted this in the Visual Basic forum, but since it has to do with VBA and both Access and Excel share VBA (somewhat) I was hoping someone here would be able to help me... I have a...
3
by: charchap | last post by:
hello. I'm experiencing problems with my css code (once again) working with Firefox and not working with IE 6 or 7 I have a problem with my head_logo_inner not too sure what's going on . Here is...
3
by: abhivg | last post by:
Hi, I am trying to port a 32 bit Unix application to 64 bit Windows. While compiling on Windows I am getting a number of warnings related to structure padding. More specifically "warning C4820:...
6
by: John Messenger | last post by:
I notice that the C standard allows padding bits in both unsigned and signed integer types. Does anyone know of any real-world examples of compilers that use padding bits? -- John
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.