Bedingte Formatierung schützen
#11
Also mit genau dem Makro funktioniert bei mir nun alles. Der Hinweis mit dem Starten funktioniert auch ohne Probleme.


Dies ist nun das aktuelle endgültige Makro, welches perfekt funktioniert. Falls dort jemand noch was ausdünnen kann/will würde ich mich freuen.

Das Forum hat mir wieder super geholfen, ich bedanke mich sehr bei allen beteidigten.

David



Code:
Sub Makro4()
'
' Makro4 Makro
'

'
    Columns("BN:BN").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
        , Formula1:="=1"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("BO:BO").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
        , Formula1:="=1"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("BP:BP").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
        , Formula1:="=1"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("BQ:BQ").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
        , Formula1:="=1"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("BN:BN").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=VERGLEICH(BN1;$A$2:$A$19;0)"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 16777164
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("BO:BO").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=VERGLEICH(BO1;$B$2:$B$36;0)"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 16777164
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("BP:BP").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=VERGLEICH(BP1;$C$2:$C$16;0)"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 16777164
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("BQ:BQ").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=VERGLEICH(BQ1;$D$2:$D$13;0)"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 16777164
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("BG:BG").Select
    Selection.FormatConditions.AddUniqueValues
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    Selection.FormatConditions(1).DupeUnique = xlDuplicate
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("BM:BM").Select
    Selection.FormatConditions.AddUniqueValues
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    Selection.FormatConditions(1).DupeUnique = xlDuplicate
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Columns("BS:BS").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
        , Formula1:="=1"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 5287936
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
End Sub
Top
#12
Hallo,

bevor ich jetzt unter die Dusche husche habe ich schnell mal hier reingeschaut.

Also, wenn ich das richtig interpretiere, dann rufst Du jetzt aus DieseArbeitsmappe
Dein Makro, welches sich weiterhin in einem normalen Modul befindet, auf und
läßt es ablaufen. Das ist ganz sicher der Weg des geringsten Wiederstandes, aber, ja,
so könnte es auch laufen. Ich könnte momentan auch nicht unbedingte Sicherheitsbedenken
geltend machen und na ja, vielleicht ist es ein wenig weniger schnell, als wenn man ...
Das allerdings ist ziemlich minimal und wird Dich nicht wirklich stören, denke ich.

Na, und wenn irgendwas unklar ist, ... Du weißt ja, wo es Hilfe geben kann.
Viel Spaß also mit Deinem Konstrukt; es ist ja letztendlich eine von Dir selbst entwickelte
Lösung.
Top
#13
Hi,

das erste Drittel Deines Makros kannst Du evtl. so kürzen:
   With Columns("BN:BQ")
     .FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
         , Formula1:="=1"
     .FormatConditions(.FormatConditions.Count).SetFirstPriority
     With .FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
     End With
     .FormatConditions(1).StopIfTrue = False
  End With
 
'   Columns("BO:BO").Select
'   Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
'       , Formula1:="=1"

'   Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
'   With Selection.FormatConditions(1).Interior
'      .PatternColorIndex = xlAutomatic
'      .Color = 255
'      .TintAndShade = 0
'   End With
'   Selection.FormatConditions(1).StopIfTrue = False
'   Columns("BP:BP").Select
'   Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
'       , Formula1:="=1"

'   Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
'   With Selection.FormatConditions(1).Interior
'      .PatternColorIndex = xlAutomatic
'      .Color = 255
'      .TintAndShade = 0
'   End With
'   Selection.FormatConditions(1).StopIfTrue = False
'   Columns("BQ:BQ").Select
'   Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
'       , Formula1:="=1"

'   Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
'   With Selection.FormatConditions(1).Interior
'      .PatternColorIndex = xlAutomatic
'      .Color = 255
'      .TintAndShade = 0
'   End With
'   Selection.FormatConditions(1).StopIfTrue = False
 
Top
#14
Hi,

also dann insgesamt so, das geht aber sicher noch kürzer:
Sub Makro4()
   ' 
   ' Makro4 Makro 
   ' 
   
   ' 
   With Columns("BN:BQ")
      .FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual, Formula1:="=1"
      .FormatConditions(.FormatConditions.Count).SetFirstPriority
      With .FormatConditions(1).Interior
         .PatternColorIndex = xlAutomatic
         .Color = 255
         .TintAndShade = 0
      End With
      .FormatConditions(1).StopIfTrue = False
   End With
   
   With Columns("BN:BN")
      .FormatConditions.Add Type:=xlExpression, Formula1:= _
          "=VERGLEICH(BN1;$A$2:$A$19;0)"
      .FormatConditions(.FormatConditions.Count).SetFirstPriority
      With .FormatConditions(1).Interior
         .PatternColorIndex = xlAutomatic
         .Color = 16777164
         .TintAndShade = 0
      End With
      .FormatConditions(1).StopIfTrue = False
   End With
   
   With Columns("BO:BO")
      .FormatConditions.Add Type:=xlExpression, Formula1:= _
          "=VERGLEICH(BO1;$B$2:$B$36;0)"
      .FormatConditions(.FormatConditions.Count).SetFirstPriority
      With .FormatConditions(1).Interior
         .PatternColorIndex = xlAutomatic
         .Color = 16777164
         .TintAndShade = 0
      End With
      .FormatConditions(1).StopIfTrue = False
   End With
   
   With Columns("BP:BP")
      .FormatConditions.Add Type:=xlExpression, Formula1:= _
          "=VERGLEICH(BP1;$C$2:$C$16;0)"
      .FormatConditions(.FormatConditions.Count).SetFirstPriority
      With .FormatConditions(1).Interior
         .PatternColorIndex = xlAutomatic
         .Color = 16777164
         .TintAndShade = 0
      End With
      .FormatConditions(1).StopIfTrue = False
   End With
   
   With Columns("BQ:BQ")
      .FormatConditions.Add Type:=xlExpression, Formula1:= _
          "=VERGLEICH(BQ1;$D$2:$D$13;0)"
      .FormatConditions(.FormatConditions.Count).SetFirstPriority
      With .FormatConditions(1).Interior
         .PatternColorIndex = xlAutomatic
         .Color = 16777164
         .TintAndShade = 0
      End With
      .FormatConditions(1).StopIfTrue = False
   End With
   
   With Columns("BG:BG")
      .FormatConditions.AddUniqueValues
      .FormatConditions(.FormatConditions.Count).SetFirstPriority
      .FormatConditions(1).DupeUnique = xlDuplicate
      With .FormatConditions(1).Interior
         .PatternColorIndex = xlAutomatic
         .Color = 255
         .TintAndShade = 0
      End With
      .FormatConditions(1).StopIfTrue = False
   End With
   
   With Columns("BM:BM")
      .FormatConditions.AddUniqueValues
      .FormatConditions(.FormatConditions.Count).SetFirstPriority
      .FormatConditions(1).DupeUnique = xlDuplicate
      With .FormatConditions(1).Interior
         .PatternColorIndex = xlAutomatic
         .Color = 255
         .TintAndShade = 0
      End With
      .FormatConditions(1).StopIfTrue = False
   End With

   With Columns("BS:BS")
      .FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
          , Formula1:="=1"
      .FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
      With .FormatConditions(1).Interior
         .PatternColorIndex = xlAutomatic
         .Color = 5287936
         .TintAndShade = 0
      End With
      .FormatConditions(1).StopIfTrue = False
   End With
End Sub
Top


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 2 Gast/Gäste