Excel VBA를 처음 만들었습니다.VBA의 실행 취소 처리기에 인수를 전달하는 방법
아래의 매크로는 기본적으로 셀 범위의 배경을 변경합니다.
GenerateMarkerOnSheet는 내부를 검은 색으로 설정합니다. ResetMarkerOnSheet는 실행 취소시 위의 변경 사항을 롤백하기위한 것입니다.
이전 인테리어를 실행 취소 핸들러 (ResetMarkerOnSheet) 에 인수로 전달할 수 있습니까? Application.OnUndo?
그렇다면 어떻게해야합니까?
Sub GenerateMarkerOnSheet()
'
' GenerateMarkerOnSheet Macro
' Macro recorded 29/01/2010 by Everyone
'
'
StartIndex = 99
RangeGap = 100
StartCell = "A"
EndCell = "BU"
PreviousBackground = 1
Do While StartIndex < 65536
For Each c In Worksheets(ActiveSheet.Name).Range(StartCell & StartIndex & ":" & EndCell & StartIndex)
If PreviousBackground = 1 Then
PreviousBackground = c.Interior.ColorIndex
End If
c.Interior.Color = RGB(0, 0, 0)
Next
StartIndex = StartIndex + RangeGap
Loop
' How to pass PreviousBackground to the call below
Application.OnUndo "Undoing", "ResetMarkerOnSheet"
End Sub
Sub ResetMarkerOnSheet()
'
' ResetMarkerOnSheet Macro
' Macro recorded 29/01/2010 by Everyone
'
'
StartIndex = 99
RangeGap = 100
StartCell = "A"
EndCell = "BU"
Do While StartIndex < 65536
For Each c In Worksheets(ActiveSheet.Name).Range(StartCell & StartIndex & ":" & EndCell & StartIndex)
c.Interior.ColorIndex = PreviousBackground
Next
StartIndex = StartIndex + RangeGap
Loop
End Sub
감사하지만 'Application.OnUndo'에서 실행 취소 처리기를 제공 할 수 있습니다. 숨겨진 작업 표를 사용하는 것이 좋습니다. 나는 그것을 줄 것이다! – Everyone