Hye,
I have coded the below as macros. It works successfully, just that consumes inconsiderable amount of time to process even just for 20 to 30 rows of data.
Appreciate if anyone who is expert to correct or improve my coding below to allow much faster processing :-
I have coded the below as macros. It works successfully, just that consumes inconsiderable amount of time to process even just for 20 to 30 rows of data.
Appreciate if anyone who is expert to correct or improve my coding below to allow much faster processing :-
Code:
Sub Rank()
Dim FPart1 As String
Dim FPart2 As String
Dim FPart3 As String
Dim LRow As Integer
Dim SRow As Integer
Application.ScreenUpdating = False
OldRow = Range("E" & Rows.Count).End(xlUp).Row
LRow = Range("B" & Rows.Count).End(xlUp).Row
SRow = Range("A2").Value
ActiveSheet.Range("E" & SRow & ":E" & OldRow).ClearContents
FPart1 = "=IF(XXXXX<=R2C6,INDEX(INDIRECT(""$B$""&R2C1&"":$B$""&LOOKUP(2,1/(C[-3]<>""""),ROW(C[-3]))),MATCH(LARGE(YYYYY,ROWS(INDIRECT(CHAR(COLUMN()+64)&""$""&R2C1&"":""&CHAR(COLUMN()+64)&ROW()))),YYYYY,0)),IF(XXXXX<=R2C6+1,""All Other"",""""))"
FPart2 = "ROWS(INDIRECT(CHAR(COLUMN()+64)&""$""&R2C1&"":""&CHAR(COLUMN()+64)&ROW()))"
FPart3 = "INDIRECT(""$D$""&R2C1&"":$D$""&LOOKUP(2,1/(C[-3]<>""""),ROW(C[-3])))"
Application.ReferenceStyle = xlR1C1
With ActiveSheet.Range("E" & SRow)
.Formula = FPart1
.Replace "XXXXX", FPart2, lookat:=xlPart
.Replace "YYYYY", FPart3, lookat:=xlPart
End With
Application.ReferenceStyle = xlA1
Range("E" & SRow).Select
Selection.AutoFill Destination:=Range("E" & SRow & ":E" & LRow)
Calculate
Range("E" & SRow & ":E" & LRow).Select
Range("E" & SRow).Select
Application.ScreenUpdating = True
End Sub