LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default conditional format based on column statistics and loop over columns

Haley,

I modified your original code to do this for you. I have not been able to test it yet with actual data, though.

Ben

Sub findoutlier()
Dim strCell As String
Dim strRange As String
Dim x As Long
Dim rRange As Range


For x = 0 To 29
'Assumes that each column has the same number of rows
Set rRange = Range("A1:A43").Offset(0, x)
strCell = "$" & Replace(rRange.Range("A1").Address, "$", vbNullString, 1)
strRange = Replace(rRange.Address, "$", vbNullString, 1)
Debug.Print strCell & vbCr & strRange

With rRange
.Select
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND(" & strCell & " < ""."", OR(" & _
strCell & "<(QUARTILE(" & strRange & ", 1)-1.5*(QUARTILE(" & _
strRange & ", 3)-QUARTILE(" & strRange & ", 1))), " & _
strCell & "(QUARTILE(" & strRange & ", 1)+1.5*(QUARTILE(" & _
strRange & ", 3)-QUARTILE(" & strRange & ", 1)))))"
.FormatConditions(.FormatConditions.Count).SetFirs tPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
End With
Next x

End Sub
 
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 format based on a different column ArcticWolf Excel Worksheet Functions 2 January 23rd 09 10:15 AM
Conditional format row based on 1 column. FStuttgen Excel Discussion (Misc queries) 3 November 4th 08 07:36 PM
conditional format on column based on cell value kixy1 Excel Worksheet Functions 2 August 22nd 08 08:52 PM
How to conditional format columns in a range based on BlyChris Excel Worksheet Functions 5 July 25th 08 06:10 AM
Conditional Format a column based on another Karm Excel Discussion (Misc queries) 6 October 30th 06 11:39 AM


All times are GMT +1. The time now is 08:40 AM.

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

About Us

"It's about Microsoft Excel"