Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1572to1576
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
Inhaltsverzeichnis

recorderaufnahme ohne select

recorderaufnahme ohne select
06.08.2017 19:17:26
Gisela
Guten Abend,
leider reichen meine Kenntnisse nur für die Benutzung des Recorders.
Den nachfolgenden Makro - geht um benutzerdefinierte Formatierung - habe ich mit dem Recorder aufgenommen. Da ich eine ganze Reihe von benutzerdefinierten Formatierungen habe und zwischendurch auch immer wieder Zeilen gelöscht werden, habe ich diese Lösung gewählt. Sie funktioniert. Ist aber leider sehr umfangreich. Kann mir bitte jemand helfen, das ganze ohne die vielen select etc. darzustellen.
Hier die Recoderaufzeichnung

Sub Formatspalten()
Range("Q9:Q300").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=Q9>0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.14996795556505
End With
Selection.FormatConditions(1).StopIfTrue = False
'spalten Q-R
Range("Q9:R300").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=R9=""a"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.Pattern = xlNone
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
'spalte R
Range("R9:R300").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=R9>"""""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
End With
Selection.FormatConditions(1).StopIfTrue = False
With Selection.Font
.Name = "Marlett"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
End 

Sub ()
Vielen Dank für jede Hilfe.
Liebe Grüße
Gisela


		

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: recorderaufnahme ohne select
06.08.2017 19:27:17
Hajo_Zi
Hallo Gisela,
Option Explicit
Sub Formatspalten()
With Range("Q9:Q300")
.FormatConditions.Add Type:=xlExpression, Formula1:="=Q9>0"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.14996795556505
End With
.FormatConditions(1).StopIfTrue = False
End With
'spalten Q-R
With Range("Q9:R300")
.FormatConditions.Add Type:=xlExpression, Formula1:="=R9=""a"""
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.Pattern = xlNone
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
End With
'spalte R
With Range("R9:R300")
.FormatConditions.Add Type:=xlExpression, Formula1:="=R9>"""""
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
End With
.FormatConditions(1).StopIfTrue = False
With .Font
.Name = "Marlett"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
End With
End Sub


Ich gebe keinen Dank für eine Rückmeldung, da ich durch solche Beiträge nicht meine Beitragszahl erhöhen muss.
Rückmeldung ist ja in der Heutigen Zeit nicht üblich und die wenigen die eine Rückmeldung geben, mögen mir das verzeihen, das kein Danke für eine Rückmeldung kommt.
Anzeige
Dank ist meine Bringschuld - Gisela - Danke
06.08.2017 19:48:42
Gisela
o.T
Weitere Code-Verkürzung
07.08.2017 06:33:07
lupo1

With Range("R9:R300")
.FormatConditions.Add Type:=xlExpression, Formula1:="=R9>"""""
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
End With
.FormatConditions(1).StopIfTrue = False
With .Font
.Name = "Marlett"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
End With
kannst Du dabei noch weiter kürzen, da der Recorder alle denkbaren Optionen einer Methode nennt, die aber meistens gar nicht gebraucht werden. Meistens wird durch Dich tatsächlich nur eine einzige Eigenschaft zugewiesen, z.B. Font "Marlett " ohne jegliche weitere Detaillierung. In den Fällen benötigt man auf der unteren Ebene dann auch keine With - End With.
Statt "ThemeColor" kann man auch "Color" nehmen, so dass es auch mit uralten Excels läuft.
Achtung: Da ich das folgende nicht getestet habe, ausdrücklich der Hinweis, dass ich eventuell im Einzelfall die falsche Eigenschaftszuweisung belassen oder gelöscht habe! Einfach selbst ausprobieren!
    With Range("R9:R300")
.FormatConditions.Add Type:=xlExpression, Formula1:="=R9>""""" 'Aus 2 Zeilen mach 1
.FormatConditions(1).Interior.ThemeColor = xlThemeColorDark1   'Aus 5 Zeilen mach 1
.FormatConditions(1).StopIfTrue = False                        'kann evtl. noch weg
.Font.Name = "Marlett"                                         'Aus 11 Zeilen mach 1
End With

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige