Hello!
My first attempt at creating an Excel VBA.
The macros below essentially change the background on the interior of a cell-range.
GenerateMarkerOnSheet sets interior to black. ResetMarkerOnSheet is meant to roll-back the above change on Undo.
Is it possible to pass the previous interior as an argument to the Undo hander (ResetMarkerOnSheet) via Application.OnUndo?
If so, How should I go about it?
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