2016-06-23 22 views
0

Ist es möglich, bestimmten Text in einer Formel mit vba zu suchen? Zum Beispiel: Ich habe eine Reihe von Index (Array-Match (Array, "Kriterien" 0), 0) und andere Summenformeln. Ich möchte Formeln mit "Index" suchen und Zellenfarbe ändern.VBA, Suchzeichenfolge innerhalb einer Formel in Excel

Bisher habe ich den folgenden Code geschrieben:

For Each cell In ActiveSheet.UsedRange 'color cells having formulas 
    If cell.HasFormula Then 
     Find = "*index*" 
     cell.Font.Color = indexcolor 
    End if 
Next cell 
+0

Ja, es ist möglich. – findwindow

+0

Wie machst du das? – user6505721

+2

Siehe [wie man fragt] (http://stackoverflow.com/help/how-to-ask). – findwindow

Antwort

0
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

0

Wie wäre:

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