Say I have a Range object for cells A1:A10 in my worksheet. These cells all contain strings of varying length, and I would like to know the length of the longest string.
Within Excel, I could use an array formula like {=MAX(LEN(A1:A10))} to find this value. I think I could set some other cell in the worksheet to use this formula and retrieve the value, but I’d rather not alter the sheet.
Is there some way I can apply this formula (or any formula, really) to a Range object directly in code and retrieve the result?
Alternatively, is there some other easy way to find this value without altering the content of the worksheet and without looping through each cell in the range?
You can use the Application.Evaluate function, e.g., in VB.Net: