G
Guest
Please explain the reson why "Act" become = 0 after the pastespecial
operation and ws_change starts? The whole reason with the Act thing is that
it _should_prevent_a_loop_ when event ws_change happens. Look at the mark at
FormatTemp sub where it all go wrong....
I can't use "Application.eventenable = false" approach because it seem to
wipe out the clipboard... . I have no other worksheet_event etc in the
workbook.
/Thanks
Private Sub Worksheet_Change(ByVal Target As Range)
' *********
' Start a format restore operation when any change take place
' Act is used as a variable to prevent a loop when ForamtTemp causes any
changes
' *********
Dim Act As Integer
' "After the pastespecial in FormatTemp causes a change, a
' msgbox show Act = 0 here - why ?????"
If Not Act = 1 Then
Call FormatTemp
Else:
Exit Sub
End If
Act = 0
End Sub
Sub FormatTemp()
'**********
'SetSaveLoc and GetSaveLoc log and activate the current worksheet, workbook
and range
'**********
Dim Act As Integer
Act = 1
ActiveSheet.Unprotect
Call SetSaveLoc
Blad200.Unprotect
Blad200.Cells.Copy
ActiveSheet.Cells.Select ' Act = 1
Selection.PasteSpecial Paste:=xlPasteFormats,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
' HERE does the above action trigg worksheet_activate
' and make Act = 0 causing a loop of some reson - why? ????
ActiveSheet.Protect AllowFormattingCells:=False
ActiveSheet.EnableSelection = xlUnlockedCells
Call GetSaveLoc
End Sub
operation and ws_change starts? The whole reason with the Act thing is that
it _should_prevent_a_loop_ when event ws_change happens. Look at the mark at
FormatTemp sub where it all go wrong....
I can't use "Application.eventenable = false" approach because it seem to
wipe out the clipboard... . I have no other worksheet_event etc in the
workbook.
/Thanks
Private Sub Worksheet_Change(ByVal Target As Range)
' *********
' Start a format restore operation when any change take place
' Act is used as a variable to prevent a loop when ForamtTemp causes any
changes
' *********
Dim Act As Integer
' "After the pastespecial in FormatTemp causes a change, a
' msgbox show Act = 0 here - why ?????"
If Not Act = 1 Then
Call FormatTemp
Else:
Exit Sub
End If
Act = 0
End Sub
Sub FormatTemp()
'**********
'SetSaveLoc and GetSaveLoc log and activate the current worksheet, workbook
and range
'**********
Dim Act As Integer
Act = 1
ActiveSheet.Unprotect
Call SetSaveLoc
Blad200.Unprotect
Blad200.Cells.Copy
ActiveSheet.Cells.Select ' Act = 1
Selection.PasteSpecial Paste:=xlPasteFormats,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
' HERE does the above action trigg worksheet_activate
' and make Act = 0 causing a loop of some reson - why? ????
ActiveSheet.Protect AllowFormattingCells:=False
ActiveSheet.EnableSelection = xlUnlockedCells
Call GetSaveLoc
End Sub