Ist bitte der Eintrag einer bedingten Formatierung mittels VBA auch möglich?
Formel ist "=ODER(ZÄHLENWENN(I2;"*kontrast*");ZÄHLENWENN(I2;"*Röntgen*"))
Farbe wäre grau.
Danke
Josef
Sub bedformatierung()
With Cells(2, 9).Interior
If Cells(2, 9) = "*kontrast*" Or Cells(2, 9) = "*Röntgen*" Then
.ColorIndex = 48
.Pattern = xlSolid
Else
.ColorIndex = xlNone
End If
End With
End Sub
GrußSub BedingtesFormat()
Dim Name
Dim Name1
Dim Name2
Dim wks As Worksheet
Dim wks1 As Worksheet
Dim Bereich As Range
Set wks = Workbooks("Masterprog.xla").Worksheets("Tabelle1")
Set wks1 = Workbooks("Masterfile.xls").Worksheets("Tabelle1")
Set Bereich = Range("I2", Cells(Rows.Count, 2).End(xlUp))
Name = wks.Range("BE1")
Name1 = wks.Range("BF1")
Name2 = wks.Range("BG1")
With wks1
Bereich.FormatConditions.Delete
Bereich.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ODER(ZÄHLENWENN(I2;Name);ZÄHLENWENN(I2;""*Name1*"");ZÄHLENWENN(I2;""*Name2*""))"
Bereich.FormatConditions(1).Interior.ColorIndex = 15
End With
End Sub
Leider klappt es mit der Deklaration nicht (Name)Sub bedformatierung()
With Range("I2", Cells(Rows.Count, 2).End(xlUp)).Interior
If Cells(2, 9) = "*kontrast*" Or Cells(2, 9) = "*Röntgen*" Then
.ColorIndex = 15
.Pattern = xlSolid
Else
.ColorIndex = xlNone
End If
End With
End Sub
GrußSub BedingtesFormat_3()
Dim wx
Dim xy
Dim yz
Dim wks As Worksheet
Dim wks1 As Worksheet
Dim bereich As Range
Set wks = Workbooks("Masterprog.xla").Worksheets("Tabelle1")
Set wks1 = Workbooks("Masterfile.xls").Worksheets("Tabelle1")
'Set bereich = Range("I2", Cells(Rows.Count, 2).End(xlUp))
Set bereich = ActiveSheet.Range("I2:I" & ActiveSheet.Range("A65536").End(xlUp).Row)
wx = wks.Range("BE1")
xy = wks.Range("BF1")
yz = wks.Range("BG1")
With wks1
bereich.FormatConditions.Delete
bereich.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ODER(ZÄHLENWENN(I2;""*" & wx & "*"");ZÄHLENWENN(I2;""*" & xy & "*"");ZÄHLENWENN(I2;""* _
" & yz & "*""))"
bereich.FormatConditions(1).Interior.ColorIndex = 15
End With
End Sub
Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen