Option
Explicit
Private
m_rngUndo
As
Excel.Range
Private
m_blnFormatFettAlt
As
Boolean
Public
Sub
BeispielAktion()
Range(
"B2"
).Value =
"Irgend ein Zelleninhalt."
Call
FormatFett(Range(
"B2"
))
End
Sub
Public
Sub
FormatFett(Range
As
Excel.Range)
Set
m_rngUndo = Range
m_blnFormatFettAlt = Range.Font.Bold
Range.Font.Bold =
True
Call
Application.OnUndo(
"Rückgängig - FormatFett"
,
"FormatFett_Undo"
)
End
Sub
Public
Sub
FormatFett_Undo()
If
m_rngUndo
Is
Nothing
Then
Exit
Sub
End
If
m_rngUndo.Font.Bold = m_blnFormatFettAlt
Set
m_rngUndo =
Nothing
End
Sub