Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 04-17-2012, 06:21 AM
Catalin.B Catalin.B is offline Highest & lowest Numbers Windows Vista Highest & lowest Numbers Office 2010 32bit
Expert
 
Join Date: May 2011
Location: Iaşi, România
Posts: 386
Catalin.B is on a distinguished road
Default

You can start from these codes, to find the highest or lowest 3 departments, and to check if they are highlighted:
Code:
Sub RankHighest()
Dim i, Rank ', Count
Dim Rng As String
Rng = "B2:B12"
For i = 2 To 12
'Find rank for cell value
Rank = WorksheetFunction.Rank(ActiveSheet.Cells(i, 2), ActiveSheet.Range(Rng))
'Check which departments ranked 1 to 3 are highlighted
If ActiveSheet.Cells(i, 1).Interior.ColorIndex <> -4142 And Rank <= 3 Then
MsgBox ActiveSheet.Cells(i, 1) & " is Ranked " & Rank & " and it is highlighted!"
End If
'Check which departments ranked 1 to 3 are NOT highlighted
If ActiveSheet.Cells(i, 1).Interior.ColorIndex = -4142 And Rank <= 3 Then
MsgBox ActiveSheet.Cells(i, 1) & " is Ranked " & Rank & " and it is NOT highlighted!"
End If
Next i

End Sub


Sub RankLowest()
Dim i, Rank, Count
Dim Rng As String
Rng = "B2:B12"
For i = 2 To 12
'Find rank for cell value
Rank = WorksheetFunction.Rank(ActiveSheet.Cells(i, 2), ActiveSheet.Range(Rng))
'Find how many departments are in range
Count = WorksheetFunction.Count(ActiveSheet.Range(Rng))
'Check if last 3 departments  are highlighted
If ActiveSheet.Cells(i, 1).Interior.ColorIndex <> -4142 And Rank >= Count - 2 Then
MsgBox ActiveSheet.Cells(i, 1) & " is Ranked " & Rank & " from " & Count & " and it is highlighted!"
End If
'Check if last 3 departments  are  NOT highlighted
If ActiveSheet.Cells(i, 1).Interior.ColorIndex = -4142 And Rank >= Count - 2 Then
MsgBox ActiveSheet.Cells(i, 1) & " is Ranked " & Rank & " from " & Count & " and it is NOT highlighted!"
End If
Next i

End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Highest &amp; lowest Numbers Page Numbers Not Matching Chapter Numbers gracie5290 Word 1 02-02-2012 11:41 PM
Highest &amp; lowest Numbers Numbers rdcrags Word 4 11-13-2011 11:11 AM
HELP...page numbers BroKyle Word 3 10-15-2011 08:59 AM
Numbers in Words janak Excel 2 12-19-2010 08:53 PM
page numbers and TOC windon Word 0 09-09-2009 07:53 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:35 PM.


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