Solved

Getting the right numberformat

Posted on 2013-12-28
8
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 11

Expert Comment

by:Gregory Miller
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 81

Expert Comment

by:byundt
ID: 39744190
I apologize for duplicating your point, Technodweeb.
0
 
LVL 11

Assisted Solution

by:Gregory Miller
Gregory Miller 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:Gregory Miller
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
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.

733 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