AW: Formate auslesen
13.10.2007 18:39:03
Daniel
Hallo
ich habs mal als benutzerdefinierte Funktion geschrieben, dann kannst du es in Excel und in VBA verwenden.
die Funkiton hat ein Boolsches Ergebnis und gibt FALSCH zurück, sobald eine Zelle im Zellbereich ein Format hat, das vom Standard abweicht.
Sobald eine Zelle ein Format hat, ist das Ergebnis WAHR.
Geprüft werden momentan Schriftart mit allen Ausprägungen, die Hintergrundfarbe, Zahlenformat und bedingte Formate.
man kann es natürlich noch für Rahmen erweitern, aber das überlasse ich dann mal dir. Das Prinzip sollte ja klar sein:
Function FormatVorhanden(bereich As Range) As Boolean
Dim x As Integer
Dim Zelle As Range
For Each Zelle In bereich
With Zelle.Font
x = x + (.Name Application.StandardFont)
x = x + .Size Application.StandardFontSize
x = x + .Strikethrough = True
x = x + .Superscript = True
x = x + .Subscript = True
x = x + .OutlineFont = True
x = x + .Shadow = True
x = x + .Underline xlUnderlineStyleNone
x = x + .ColorIndex xlAutomatic
x = x + .Bold = True
x = x + .Italic = True
End With
With Zelle
x = x + .Interior.ColorIndex xlNone
x = x + (.NumberFormat "General")
x = x + .FormatConditions.Count
End With
If x 0 Then Exit For
Next
FormatVorhanden = CBool(x)
End Function
bedenke allerdings, daß Format-Änderungen keine Neuberechung auslösen, und eine Formel nur dann neu berechnet wird, wenn eine Zelle des Zellbezugs geändert wird.
wenn du die Formel in Excel einsetzt, ist sie daher nur für den Augenblick der Eingabe gülitg.
beim Einsatz in VBA ist das kein Problem.
Gruß, Daniel