Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-22-2011, 11:08 PM
macropod's Avatar
macropod macropod is offline Comma style without trailing zeroes but with decimal part Windows 7 64bit Comma style without trailing zeroes but with decimal part Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,479
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

Hi Scaffold,

You could employ a UDF in the relevant worksheet's code module, coded along the lines of:


Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static oCell As Range, bVal As Boolean
If oCell Is Nothing Then Set oCell = ActiveCell
If Intersect(oCell, ActiveSheet.Range("A2:C2")) Is Nothing Then Exit Sub
With oCell
  If IsNumeric(.Value) = False Then Exit Sub
  bVal = (CLng(.Value) = Val(.Value))
  If bVal = True Then
    .NumberFormat = "#,##0"
  Else
    .NumberFormat = "#,##0.00"
  End If
End With
End Sub
The above will apply your formatting to any cell in the A2:C2 range. Adjust to suit your needs.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Comma style without trailing zeroes but with decimal part Applying style to first part of paragraph foxtrot Word 3 07-24-2012 07:30 AM
Adding comma to a custom type. mcook Excel 1 08-13-2011 03:08 AM
adding a comma in end of each line in word juanb007 Word 0 07-23-2010 01:28 PM
Comma style without trailing zeroes but with decimal part thousands comma separator taylormayd Excel 3 02-20-2009 03:46 AM
Comma style without trailing zeroes but with decimal part How to stop correcting zeroes in cells ? kevin_ms Excel 4 09-14-2008 10:08 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:02 AM.


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