Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-24-2013, 07:55 AM
funkyfido funkyfido is offline Number formatting Windows XP Number formatting Office 2007
Novice
Number formatting
 
Join Date: Jun 2013
Posts: 24
funkyfido is on a distinguished road
Default Number formatting

Hi
I am currently doing a vlookup and on the value returned I want the format to change. I want the cell to be formatted in thousands and also have the thousand separator if the actual figure is in millions.
e.g. 1234567 should be 1,235
-1234567 should be (1,235) in red

The code I am currently using is
Selection.NumberFormat = "0," (this returns 1235 or -1235)




Any ideas how to get it all?
Reply With Quote
  #2  
Old 10-01-2013, 01:22 AM
macropod's Avatar
macropod macropod is offline Number formatting Windows 7 32bit Number formatting Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by funkyfido View Post
Hi
I am currently doing a vlookup and on the value returned I want the format to change. I want the cell to be formatted in thousands and also have the thousand separator if the actual figure is in millions.
e.g. 1234567 should be 1,235
-1234567 should be (1,235) in red

The code I am currently using is
Selection.NumberFormat = "0," (this returns 1235 or -1235)


Any ideas how to get it all?
You can use a custom number format:
0,0,;-0,0,[Red]
or:
#,#00,;[Red]-#,#00,

If you format the cells that way beforehand, there's no need to do it in code; otherwise, try:
Selection.NumberFormat = "0,0,;-0,0,[Red]"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Number formatting Conditional Formatting for a change in number Alaska1 Excel 11 07-30-2013 04:01 AM
Number formatting Number and date formatting dmarie123 Word VBA 5 02-28-2013 03:10 PM
Number formatting Phone number formatting Mark Micallef Outlook 1 08-04-2010 02:38 PM
Number formatting in Word table 8braitp Word Tables 0 08-27-2009 04:12 AM
Different page number formatting. gerrie Word 0 04-15-2006 07:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft