I am trying to use "conditional" Large function in my code e.g. to use Large function for values where in the other column there is "Y".
I am using "Evaluate" function as I need only the results in the other part of the code. However, this is not working - I understand that I need to work with Formula2 because otherwise excel will add '@' to the function and it wont work. But still I dont know how to 'repair' evaluate function.
I am using R1C1 formula because later I want to use columns in the loop.
Sub Makro()
'not working - there is '@' included
Range("G3") = "=Large(if(c[-4]:c[-4]=""Y"", c[-3]),2)"
'working
Range("G4").Formula2 = "=Large(if(c[-4]:c[-4]=""Y"", c[-3]),2)"
'not working
Range("G5") = Evaluate("=Large(if(c[-4]:c[-4]=""Y"", c[-3]),2)")
End Sub
Evaluate..Formula2R1C1instead of.Formula2.ActiveSheet.Range("G4").Value = ActiveSheet.Evaluate("LARGE(IF(C:C=""Y"",D:D),2)")work?Evaluate("=Large(if(C:C=""Y"", D:D),2)")is working for me. I understand that I need to work with funtion in that form (A1 instead of R1C1). What is the best solution to re-write my function to adjust for the loop?Evaluate("=Large(if(C:C=""Y"", D:D),2)"), Evaluate("=Large(if(C:C=""Y"", E:E),2)"), Evaluate("=Large(if(C:C=""Y"", F:F),2)"), ...., Evaluate("=Large(if(C:C=""Y"", Z:Z),2)")G4:AC4orG4:G27or...? In the same worksheet? Also, you may want to restrict the columns to e.g.D5:DLastRowto not severely slow down your workbook.