Hallo,
die Formatierungen lassen sich mit den Standardereignissen nur schwer abfangen; eine Möglichkeit wäre einen Api-Timer im Hintergrund laufen zu lassen, den Du beim Betreten und Verlasssen des TabBlattes aktivierst bzw. deaktivierst:
Code in das Klassenmodul des Tabellenblattes:
Option Explicit
Private Sub Worksheet_Activate()
Call prcStartTimer
End Sub
Private Sub Worksheet_Deactivate()
Call prcStopTimer
End Sub
Code in ein Standardmodul:
Option Explicit
Option Private Module
Private Declare Function SetTimer Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
Public Sub prcStartTimer()
SetTimer Application.hwnd, 0&, 1&, AddressOf TimerProc
End Sub
Public Sub prcStopTimer()
KillTimer Application.hwnd, 0&
End Sub
Private Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long)
Static sobjRange As Range
On Error Resume Next
If ActiveCell.Borders(xlEdgeBottom).LineStyle = xlNone Then _
Set sobjRange = ActiveCell
If ActiveCell.Borders(xlEdgeBottom).LineStyle <> xlNone And _
ActiveCell.Address = sobjRange.Address Then _
Cells(1, 1) = ActiveCell.Address & " ist unterstrichen"
If Err Then Set sobjRange = Nothing
End Sub
Gruß,
|