Solved

Getting the right numberformat

Posted on 2013-12-28
8
232 Views
Last Modified: 2013-12-28
Folks,
I've been trying to set the numberformat to display a specific format with VBA:
Selection.NumberFormat = "##0"

Open in new window

That did not work not has other formats I've tried.

Here's my objective
123
1230
0

What is the correct NumberFormat to meet my objective?
0
Comment
Question by:Frank Freese
  • 3
  • 3
  • 2
8 Comments
 
LVL 11

Expert Comment

by:Technodweeb
ID: 39744181
Not certain I follow...
Can you show the number you have in the cell and the number you want it to be displayed like. i.e.
123 - should become - 1230
or
123 - should become - 120
or
something else?
0
 
LVL 81

Expert Comment

by:byundt
ID: 39744185
Your code is working for me, so I obviously am not understanding your question.

Could you please post both cell contents and how you want them displayed?
0
 

Author Comment

by:Frank Freese
ID: 39744189
This is the type of format I need to show.
A1 = 123
A2 = 1230
A3 = 0
(All numbers are integers)

Sometimes I get nothing when the value is 0
Sometime I get 001230 when the value is 1230
0
 
LVL 81

Expert Comment

by:byundt
ID: 39744190
I apologize for duplicating your point, Technodweeb.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Assisted Solution

by:Technodweeb
Technodweeb earned 100 total points
ID: 39744192
Sorry to be dense but you are not clear on what the raw number in the cell is and how you want it to be displayed.
0
 
LVL 11

Expert Comment

by:Technodweeb
ID: 39744194
@byundt - No worries... =>
0
 
LVL 81

Accepted Solution

by:
byundt earned 400 total points
ID: 39744195
If you don't want commas, leading zeros or decimal points, how about:
Selection.NumberFormat = "#;-#;0;@"
0
 

Author Closing Comment

by:Frank Freese
ID: 39744206
byundt's format worked.
To the two of you I apologize for being rather vague.
Thank you both
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now