Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
700to704
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
700to704
700to704
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Bombenlegerformel - bed. Formatierung

Bombenlegerformel - bed. Formatierung
25.11.2005 09:10:49
Horst
Hallo,
fand ein kurzes script, müßte aber meine Formatierung darin eingebunden haben. Meine Versuche schlugen fehl. Textspalte F hat 3 Begriffe, die jeweils Rot, Blau und Schwarz für die gesamte Tabelle steuern. Bereich 1 (B:M) soll nur schriftfarblich aufgrund F; Bereich 2 (O:GT) sind durch Eingabe von X oder R Hintergrund und Schriftfarbe sofort aufgrund Spalte F zu ändern und Bereich 3 (GV:HC) wie Bereich 1. Wer kann mir das mit einbinden? Wäre sehr dankbar!!
gefunden und schön kurz:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ber As Range
Set ber = Intersect(Target, Range("B6:AF20"))
If Not ber Is Nothing Then
With ber.Interior
Select Case ber(1).Value
Case 1
.ColorIndex = 1
Case 2
.ColorIndex = 2
Case 3
.ColorIndex = 3
Case 4
.ColorIndex = 4
Case 5
.ColorIndex = 5
Case 6
.ColorIndex = 6
Case Else
.ColorIndex = xlColorIndexNone
End Select
End With
End If
End Sub

meine Makroaufzeichnung (Formatierung einbinden):
Sub bedingt_Format2()
' Textzeilen bedingte Formatierung Rot, Blau, Schwarz
Application.Goto Reference:="Format2"
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$F5=""2x/Woche"""
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$F5=""1x/Woche"""
With Selection.FormatConditions(2).Font
.Bold = True
.Italic = False
.ColorIndex = 5
End With
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$F5=""1x/Monat"""
With Selection.FormatConditions(3).Font
.Bold = True
.Italic = False
.ColorIndex = 1
End With
Selection.Copy
ActiveWindow.LargeScroll Down:=15
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("D5").Select
End Sub
Sub bedingt_Format1()
Application.Goto Reference:="Format1"
'Austausch X zu R
' ActiveWorkbook.Save
Selection.Replace What:="X", Replacement:="R", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
' bedingtes Format Rot, Blau, Schwarz
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=UND($F5=""2x/Woche"";ODER(O5=""R"";O5=""X""))"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(1).Interior.ColorIndex = 3
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=UND($F5=""1x/Woche"";ODER(O5=""R"";O5=""X""))"
With Selection.FormatConditions(2).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(2).Interior.ColorIndex = 5
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=UND($F5=""1x/Monat"";ODER(O5=""R"";O5=""X""))"
With Selection.FormatConditions(3).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
Selection.FormatConditions(3).Interior.ColorIndex = 1
Range("d5").Select
End Sub
Sub bedingt_Format3()
Application.Goto Reference:="Format3"
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$F5=""2x/Woche"""
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$F5=""1x/Woche"""
With Selection.FormatConditions(2).Font
.Bold = True
.Italic = False
.ColorIndex = 5
End With
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$F5=""1x/Monat"""
With Selection.FormatConditions(3).Font
.Bold = True
.Italic = False
.ColorIndex = 1
End With
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Columns("GV:HC").Select
Selection.ColumnWidth = 8
Range("d5").Select
End Sub

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
vielleicht so?
25.11.2005 10:31:16
ingoG
Hallo Horst,
hab das macro mal etwas angepasst
die Case-bedingungen und die dahinterstehenden Formate mußt Du jedoch jeweils noch anpassen.
Vielleicht hilft dir das ja weiter...
Gruß Ingo
PS eine Rückmeldung wäre nett...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ber1 As Range
Dim ber2 As Range
Dim ber3 As Range
Set ber1 = Intersect(Target, Range("Format1"))
Set ber2 = Intersect(Target, Range("Format2"))
Set ber3 = Intersect(Target, Range("Format3"))
ber1.FormatConditions.Delete
ber2.FormatConditions.Delete
ber3.FormatConditions.Delete
If Not ber1 Is Nothing Then
With ber1.Interior
Select Case ber1.Value
Case 1
.ColorIndex = 1
Case 2
.ColorIndex = 2
Case 3
.ColorIndex = 3
Case Else
.ColorIndex = xlColorIndexNone
End Select
End With
ElseIf Not ber2 Is Nothing Then
With ber2.Interior
Select Case ber2.Value
Case 1
.ColorIndex = 1
Case 2
.ColorIndex = 2
Case 3
.ColorIndex = 3
Case Else
.ColorIndex = xlColorIndexNone
End Select
End With
ElseIf Not ber3 Is Nothing Then
With ber3.Interior
Select Case ber3.Value
Case 1
.ColorIndex = 1
Case 2
.ColorIndex = 2
Case 3
.ColorIndex = 3
Case Else
.ColorIndex = xlColorIndexNone
End Select
End With
End If
End Sub

Anzeige
AW: vielleicht so?
25.11.2005 12:55:28
Horst
Hi Ingo,
danke! Aber wie und wo trage ich das Format für den Bereich2 ein, da die Zelle dann in der Farbe Hintergrund sein soll (wenn "X") und der eingegebene Buchstabe soll dann in Weiß erscheinen
wie ist das richtig zu plazieren:
Case 1
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$F5=""2x/Woche"""
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 1
Oder wie muss das eingegtragen werden? Kannst Du mir das schreiben? wäre super.
Gruß
Horst

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige