Is it possible to search specific text in a formula using vba? For example: I have a bunch of index(array match(array,"criteria"0),0) and other sum formulas. I want to search formulas with "index" and change cells color.
Thus far I have written the following code:
For Each cell In ActiveSheet.UsedRange 'color cells having formulas
If cell.HasFormula Then
Find = "*index*"
cell.Font.Color = indexcolor
End if
Next cell
How about:
Sub LookinForDory()
Dim r As Range, s As String
For Each r In ActiveSheet.UsedRange.Cells.SpecialCells(xlCellTypeFormulas)
s = LCase(r.Formula)
If InStr(1, s, "index") > 0 Then
r.Interior.ColorIndex = 27
End If
Next r
End Sub
Sub Changecellcolor()
Dim formulaColor As Long
Dim cell As Range
LinkedCells = RGB(Red:=0, Green:=0, Blue:=255)
For Each cell In ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas)
If InStr(1, cell.Formula, "index") > 0 Then
cell.Font.Color = LinkedCells
End If
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.