Solved

Getting the right numberformat

Posted on 2013-12-28
8
264 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

717 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