Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need to expand Macro


How do I expand this macro from ABC to A+ A B C D?


Public Function ABCRank(Test_Value As Single, Test_Range As Range,
Upper_Cutoff As Single, Lower_Cutoff As Single)

Application.Volatile

Dim A_Rank As Single
Dim B_Rank As Single
Dim C_Rank As Single

A_Rank = Excel.WorksheetFunction.Percentile(Test_Range,
Upper_Cutoff)
A_Rank = Format(A_Rank, "0.00")
C_Rank = Excel.WorksheetFunction.Percentile(Test_Range,
Lower_Cutoff)
C_Rank = Format(C_Rank, "0.00")

Select Case Test_Value
Case Is = A_Rank
ABCRank = "A"
Case Is <= C_Rank
ABCRank = "C"
Case Else
If Test_Value < A_Rank And Test_Value C_Rank Then
ABCRank = "B"
Else
ABCRank = "Error"
End If
End Select

End Function


+-------------------------------------------------------------------+
|Filename: ABC-1.zip |
|Download: http://www.excelforum.com/attachment.php?postid=4391 |
+-------------------------------------------------------------------+

--
nander
------------------------------------------------------------------------
nander's Profile: http://www.excelforum.com/member.php...fo&userid=6156
View this thread: http://www.excelforum.com/showthread...hreadid=515592

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Need to expand Macro

This is UNTESTED: if the cutoffs are non-volatile, you could hold them as an
array in the function, pass only the test value, and compare this against the
array.

Public Function ABCRank(Test_Value As Single, Test_Range As Range, _
AA_Cutoff As Single, A_Cutoff As Single, B_Cutoff As Single, C_Cutoff As
Single)

Application.Volatile

Dim AA_Rank As Single
Dim A_Rank As Single
Dim B_Rank As Single
Dim C_Rank As Single

AA_Rank = Excel.WorksheetFunction.Percentile(Test_Range, AA_Cutoff)
AA_Rank = Format(AA_Rank, "0.00")
A_Rank = Excel.WorksheetFunction.Percentile(Test_Range, A_Cutoff)
A_Rank = Format(A_Rank, "0.00")
B_Rank = Excel.WorksheetFunction.Percentile(Test_Range, B_Cutoff)
B_Rank = Format(B_Rank, "0.00")
C_Rank = Excel.WorksheetFunction.Percentile(Test_Range, C_Cutoff)
C_Rank = Format(C_Rank, "0.00")

Select Case Test_Value
Case Is = AA_Rank
ABCRank = "A+"
Case Is = A_Rank
ABCRank = "A"
Case Is = B_Rank
ABCRank = "B"
Case Is <= D_Rank
ABCRank = "D"
Case Else
If Test_Value < B_Rank And Test_Value D_Rank Then
ABCRank = "C"
Else
ABCRank = "Error"
End If
End Select

"nander" wrote:


How do I expand this macro from ABC to A+ A B C D?


Public Function ABCRank(Test_Value As Single, Test_Range As Range,
Upper_Cutoff As Single, Lower_Cutoff As Single)

Application.Volatile

Dim A_Rank As Single
Dim B_Rank As Single
Dim C_Rank As Single

A_Rank = Excel.WorksheetFunction.Percentile(Test_Range,
Upper_Cutoff)
A_Rank = Format(A_Rank, "0.00")
C_Rank = Excel.WorksheetFunction.Percentile(Test_Range,
Lower_Cutoff)
C_Rank = Format(C_Rank, "0.00")

Select Case Test_Value
Case Is = A_Rank
ABCRank = "A"
Case Is <= C_Rank
ABCRank = "C"
Case Else
If Test_Value < A_Rank And Test_Value C_Rank Then
ABCRank = "B"
Else
ABCRank = "Error"
End If
End Select

End Function


+-------------------------------------------------------------------+
|Filename: ABC-1.zip |
|Download: http://www.excelforum.com/attachment.php?postid=4391 |
+-------------------------------------------------------------------+

--
nander
------------------------------------------------------------------------
nander's Profile: http://www.excelforum.com/member.php...fo&userid=6156
View this thread: http://www.excelforum.com/showthread...hreadid=515592


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Need to expand Macro

Sorry - mistake in previous version (this is still untested):

Public Function ABCRank(Test_Value As Single, Test_Range As Range, _
AA_Cutoff As Single, A_Cutoff As Single, B_Cutoff As Single, D_Cutoff As
Single)

Application.Volatile

Dim AA_Rank As Single
Dim A_Rank As Single
Dim B_Rank As Single
Dim D_Rank As Single

AA_Rank = Excel.WorksheetFunction.Percentile(Test_Range, AA_Cutoff)
AA_Rank = Format(AA_Rank, "0.00")
A_Rank = Excel.WorksheetFunction.Percentile(Test_Range, A_Cutoff)
A_Rank = Format(A_Rank, "0.00")
B_Rank = Excel.WorksheetFunction.Percentile(Test_Range, B_Cutoff)
B_Rank = Format(B_Rank, "0.00")
D_Rank = Excel.WorksheetFunction.Percentile(Test_Range, D_Cutoff)
D_Rank = Format(D_Rank, "0.00")

Select Case Test_Value
Case Is = AA_Rank
ABCRank = "A+"
Case Is = A_Rank
ABCRank = "A"
Case Is = B_Rank
ABCRank = "B"
Case Is <= D_Rank
ABCRank = "D"
Case Else
If Test_Value < B_Rank And Test_Value D_Rank Then
ABCRank = "C"
Else
ABCRank = "Error"
End If
End Select

End Function

"Toppers" wrote:

This is UNTESTED: if the cutoffs are non-volatile, you could hold them as an
array in the function, pass only the test value, and compare this against the
array.

Public Function ABCRank(Test_Value As Single, Test_Range As Range, _
AA_Cutoff As Single, A_Cutoff As Single, B_Cutoff As Single, C_Cutoff As
Single)

Application.Volatile

Dim AA_Rank As Single
Dim A_Rank As Single
Dim B_Rank As Single
Dim C_Rank As Single

AA_Rank = Excel.WorksheetFunction.Percentile(Test_Range, AA_Cutoff)
AA_Rank = Format(AA_Rank, "0.00")
A_Rank = Excel.WorksheetFunction.Percentile(Test_Range, A_Cutoff)
A_Rank = Format(A_Rank, "0.00")
B_Rank = Excel.WorksheetFunction.Percentile(Test_Range, B_Cutoff)
B_Rank = Format(B_Rank, "0.00")
C_Rank = Excel.WorksheetFunction.Percentile(Test_Range, C_Cutoff)
C_Rank = Format(C_Rank, "0.00")

Select Case Test_Value
Case Is = AA_Rank
ABCRank = "A+"
Case Is = A_Rank
ABCRank = "A"
Case Is = B_Rank
ABCRank = "B"
Case Is <= D_Rank
ABCRank = "D"
Case Else
If Test_Value < B_Rank And Test_Value D_Rank Then
ABCRank = "C"
Else
ABCRank = "Error"
End If
End Select

"nander" wrote:


How do I expand this macro from ABC to A+ A B C D?


Public Function ABCRank(Test_Value As Single, Test_Range As Range,
Upper_Cutoff As Single, Lower_Cutoff As Single)

Application.Volatile

Dim A_Rank As Single
Dim B_Rank As Single
Dim C_Rank As Single

A_Rank = Excel.WorksheetFunction.Percentile(Test_Range,
Upper_Cutoff)
A_Rank = Format(A_Rank, "0.00")
C_Rank = Excel.WorksheetFunction.Percentile(Test_Range,
Lower_Cutoff)
C_Rank = Format(C_Rank, "0.00")

Select Case Test_Value
Case Is = A_Rank
ABCRank = "A"
Case Is <= C_Rank
ABCRank = "C"
Case Else
If Test_Value < A_Rank And Test_Value C_Rank Then
ABCRank = "B"
Else
ABCRank = "Error"
End If
End Select

End Function


+-------------------------------------------------------------------+
|Filename: ABC-1.zip |
|Download: http://www.excelforum.com/attachment.php?postid=4391 |
+-------------------------------------------------------------------+

--
nander
------------------------------------------------------------------------
nander's Profile: http://www.excelforum.com/member.php...fo&userid=6156
View this thread: http://www.excelforum.com/showthread...hreadid=515592


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
expand row to fit Peter Excel Worksheet Functions 2 May 6th 10 03:45 AM
Looking to Expand on Text to Columns Macro Jenny B. Excel Discussion (Misc queries) 2 August 30th 07 06:52 PM
Dana: help with your Demo() macro to "expand" formulas joeu2004 Excel Worksheet Functions 1 June 7th 07 08:42 AM
Use a macro to expand data series for chart? Kevin Clark Charts and Charting in Excel 0 June 21st 06 07:31 PM
Macro to expand formulas to additional rows Sharon P Excel Discussion (Misc queries) 1 January 4th 06 02:02 PM


All times are GMT +1. The time now is 06:00 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"