Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default conditional formatting

I want to select a column of numbers (B1:B1200) and format them with 4
decimals if they're between zero and one and with 2 decimals otherwise. I'd
like to do this without an add-in (vba is ok). Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default conditional formatting

Just run:

Public Sub reform()
Set r = Range("B1:B1200")
For Each rr In r
v = rr.Value
If v 0 And v <= 1 Then
rr.NumberFormat = "0.0000"
Else
rr.NumberFormat = "0.00"
End If
Next
End Sub

and each item in the column will be correctly formatted.
--
Gary''s Student - gsnu200750


"Steve" wrote:

I want to select a column of numbers (B1:B1200) and format them with 4
decimals if they're between zero and one and with 2 decimals otherwise. I'd
like to do this without an add-in (vba is ok). Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default conditional formatting

One way:

Format/Cells/Number/Custom

[<0]-0.00;[<=1]0.0000;0.00


In article ,
Steve wrote:

I want to select a column of numbers (B1:B1200) and format them with 4
decimals if they're between zero and one and with 2 decimals otherwise. I'd
like to do this without an add-in (vba is ok). Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 772
Default conditional formatting

For positive numbers:
=IF(B11,ROUND(B1,2),ROUND(B1,4))

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Steve" wrote:

I want to select a column of numbers (B1:B1200) and format them with 4
decimals if they're between zero and one and with 2 decimals otherwise. I'd
like to do this without an add-in (vba is ok). Thanks.

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
conditional Formatting based on cell formatting Totom Excel Worksheet Functions 3 January 20th 07 02:02 PM
conditional Formatting based on cell formatting Totom Excel Worksheet Functions 0 January 15th 07 04:35 PM
=IF - conditional formatting Mel Excel Discussion (Misc queries) 1 June 19th 06 02:53 PM
Conditional formatting felipe Excel Discussion (Misc queries) 3 November 28th 05 06:15 PM
Conditional Formatting that will display conditional data BrainFart Excel Worksheet Functions 1 September 13th 05 05:45 PM


All times are GMT +1. The time now is 12:31 AM.

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"