Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default Fomat with Code Q

I wish to format an existing sheet so that all negative values show in
red. This seems simple, but I have a few problems:-

1) Its a very large sheet and,
2) I can't format all ranges within a column as I have dates in some
rows which I wish to leave as is

How then could I format via code:-

So a negative value would shows as -1,234.56 (in red)
And a postive value would shows as 1,234.56 (in black)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Fomat with Code Q

go to the menu FORMAT / STYLES and with Normal in the style name, click Modify

in the modify form select the number tab, then set it as you want, click OK
then OK








"Seanie" wrote:

I wish to format an existing sheet so that all negative values show in
red. This seems simple, but I have a few problems:-

1) Its a very large sheet and,
2) I can't format all ranges within a column as I have dates in some
rows which I wish to leave as is

How then could I format via code:-

So a negative value would shows as -1,234.56 (in red)
And a postive value would shows as 1,234.56 (in black)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Fomat with Code Q

Sub dk()
For Each c In ActiveSheet.UsedRange.Cells
If c.Value < 0 Then
c.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
End If
Next
End Sub



"Seanie" wrote in message
...
I wish to format an existing sheet so that all negative values show in
red. This seems simple, but I have a few problems:-

1) Its a very large sheet and,
2) I can't format all ranges within a column as I have dates in some
rows which I wish to leave as is

How then could I format via code:-

So a negative value would shows as -1,234.56 (in red)
And a postive value would shows as 1,234.56 (in black)



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default Fomat with Code Q

Thanks, I'd do it that way, but I've 1500 rows of data over 25 columns
within which I have 35 rows of dates, which I don't want to touch, so
that is the main issue in doing a 'mass' format.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default Fomat with Code Q

Thanks, quite an imaginative piece of code

This changes all values that are currently less than 1 to a minus red,
but how can I change even values that are positive to to show as
1,234.56 (in black) - I know theu won't change, but this way it helps
me maintaining my sheet going forward




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Fomat with Code Q

Unless you specifically change them to another color, they should
automatically appear in black. Only the negative numbers should appear in
red.


"Seanie" wrote in message
...
Thanks, quite an imaginative piece of code

This changes all values that are currently less than 1 to a minus red,
but how can I change even values that are positive to to show as
1,234.56 (in black) - I know theu won't change, but this way it helps
me maintaining my sheet going forward




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fomat Cell Harold Excel Discussion (Misc queries) 3 May 14th 08 11:07 PM
how do I fomat cell for latitude Charlie Excel Discussion (Misc queries) 1 October 2nd 06 12:50 PM
Day and language fomat Tom Excel Programming 2 September 16th 06 07:02 PM
Time Fomat Thornpaw Excel Worksheet Functions 3 February 13th 06 02:21 PM
Fomat change gregork Excel Programming 4 December 6th 04 02:36 AM


All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"