Posted 13 December 2022, 9:24 pm EST
- Updated 13 December 2022, 9:29 pm EST
As per the developers, This behavior is intended. Because Microsoft Excel looks in all cells in the worksheet of the specified Range if the Range is a cell.
Range(“A1”).FormulaR1C1 = “=1+2”
Range(“A2”).FormulaR1C1 = “=2+3”
Set a3FindFormulas = Range(“A3”).SpecialCells(xlCellTypeFormulas)
f you want to check whether a range has formula cells, you need to use Range.Count and Range.HasFormula first.
If Range.Count =1 then use Range.HasFormula . Otherwise, use Range.SpecialCells.
private static IRange FindFormulaCellsExact(IRange lookIn)
if (lookIn == null)
if (lookIn.Count < 2)
return lookIn.HasFormula ? lookIn : null;