Solved

Getting the right numberformat

Posted on 2013-12-28
8
220 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 80

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 80

Expert Comment

by:byundt
ID: 39744190
I apologize for duplicating your point, Technodweeb.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 80

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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

17 Experts available now in Live!

Get 1:1 Help Now