Dear ONLYOFFICE Community!
Maybe you can help me with the following issue.
I would like to add a button in my spreadsheet document that triggers a macro. I want the macro to search my sheet for cells including a specific term and highlight those cells with a color (let’s say yellow)
If possible, it might be the case that the cells that I want to search also have some other information, so the search should not get affected by that other information (for example, from the functions I know that I would need to use the “* term *” way and not the " term " way.
Then finally I would also like to have a “revert” button that searches the highlighted text/cell (let’s say it searches a specific color e.g. yellow) and reset the highlight formating of the cell as it was before (e.g. white). If it is not possible through color search then it would also be ok if it searches the affected cells with the term again but this time it inverts them back to the white cell color.
I hope this makes sense. I appreciate the time and effort for helping me. Thanks!
Alex
EDIT: I found a script for Visual Basic that works perfectly on MS Excel, but unfortunately I do not know how to convert it to javascript. I attach it as a reference:
Sub HighlightCells()
Dim ws As Worksheet
Dim searchTerm As String
Dim cell As Range
Set ws = ThisWorkbook.Sheets("Sheet1")
searchTerm = "TermExampleHere"
ws.Cells.Interior.ColorIndex = xlNone
For Each cell In ws.UsedRange
If InStr(1, cell.Value, searchTerm, vbTextCompare) > 0 Then
cell.Interior.Color = RGB(255, 255, 0)
End If
Next cell
End Sub