Free Support Forum - aspose.com

Find cell by contains

Hi Laurence,

Is it possible that I can find a cell by looking at the formula contains?
for example, I have some average formula cells, but I do not know what is the range of that average. The function findformula is looking for exact formula includes the range. Is it possible that I can find those cells? like run cells.find("=average", Nothing)

Thank you

Ok. I will add a new FindFormulaContains method in the next fix.

Hi Laurence,

Thank you and thanks for you team the great job you guys have done.

And thank you for the function FindFormulaContains. But…Wink I have a question about this function. Is it the same like getrangebyname? It return the first cell that contains the formula, if I have more than 1 cell have SUM and
For i As Int32 = 0 To 9
excel.Worksheets(0).Cells.FindFormulaContains(“SUM”, Nothing).PutValue(“found”)
Next
it will return System.NullReferenceException’
Additional information: Object reference not set to an instance of an object.

Any suggestion?

Thank you

Please change your code as following:

Dim previousCell as Cell = Nothing
Dim foundCell as Cell

Do
foundCell = excel.Worksheets(0).Cells.FindFormulaContains(“SUM”, previousCell)
If(foundCell <> Nothing)
Exit
End If
foundCell.PutValue(“hello”)
previousCell = foundCell
Loop

Sorry, there is a mistake. I am not familiar with VB.


Following code is correct:

Dim previousCell as Cell = Nothing
Dim foundCell as Cell

Do
foundCell = excel.Worksheets(0).Cells.FindFormulaContains(“SUM”, previousCell)
If(foundCell = Nothing)
Exit Do
End If
foundCell.PutValue(“hello”)
previousCell = foundCell
Loop