I am getting type mismatch 13 error and I can’t see where it is.
Here is the code.
Set concRange = Range(Cells(11, 48), Cells((10 + noDilutions), 48))
Set deadRange = Range(Cells(11, 49), Cells((10 + noDilutions), 49))
analysisSheet.Cells(f, 14).Value = _
(WorksheetFunction.Lookup(WorksheetFunction.Index(deadRange, _
WorksheetFunction.CountIf(deadRange, " >= " & _
(WorksheetFunction.Max(deadRange) / 2))), deadRange, concRange)) _
- (((WorksheetFunction.Index(deadRange, WorksheetFunction.CountIf _
(deadRange, " >= " & (WorksheetFunction.Max(deadRange) / 2)))) _
- (WorksheetFunction.Max(deadRange) / 2)) * ((WorksheetFunction.Lookup _
(WorksheetFunction.Index(deadRange, WorksheetFunction.CountIf(deadRange, _
" >= " & (WorksheetFunction.Max(deadRange) / 2))), deadRange, concRange)) _
- (WorksheetFunction.Lookup(WorksheetFunction.Index(deadRange, _
WorksheetFunction.CountIf(deadRange, " <= " & _
(WorksheetFunction.Max(deadRange) / 2))), deadRange, concRange))) _
/ ((WorksheetFunction.Index(deadRange, WorksheetFunction.CountIf(deadRange, _
" >= " & (WorksheetFunction.Max(deadRange) / 2)))) _
- (WorksheetFunction.Index(deadRange, WorksheetFunction.CountIf _
(deadRange, " <= " & (WorksheetFunction.Max(deadRange) / 2))))))
I’ve tried changing “WorksheetFunction” to “Application” and “Application.WorksheetFunction”.
Yes it is a very very long formula 😀
Can anyone help me out?
First of all, writting a formula like that is a really bad idea, for three main reasons:
Refactoring, it becomes
Debugging this reveals the problem: the
spacesaround>=in.CountIf(deadRange, " >= " & (A / 2))is the cause of the error.So, use instead