|
本帖最后由 wudechun 于 2016-10-21 21:37 编辑
上面这个程序是将操作的地址和原值记录到"Log(测试)"这个表中,下面的test_撤消()是将所记录的地址跟原值恢复。
- '高亮所选行,辅助确定部门----------------------------
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Dim i As Long
- Dim LLogTolNum As Long
-
- LLogTolNum = Sheets("log(测试)").[a65536].End(xlUp).row
-
- With Sheets("Log(测试)")
- .Cells(LLogTolNum + 1, "A") = LLogTolNum - 1
- .Cells(LLogTolNum + 1, "B") = Target.address
- .Cells(LLogTolNum + 1, "C") = Target.Value
- End With
-
- i = Target.row
- If 上一个着色行 <> 0 Then
- Range("E" & 上一个着色行 & ":N" & 上一个着色行).Interior.ColorIndex = xlNone
- End If
- Range("E" & i & ":N" & i).Interior.ColorIndex = 28
- 上一个着色行 = i
- End Sub
- Sub test_撤消()
- Dim LLogTolNum As Long
- Dim i As Long
- Dim address As String
- Dim 值
-
- LLogTolNum = Sheets("log(测试)").[a65536].End(xlUp).row
- For i = LLogTolNum To 2 Step -1
- address = Sheets("Log(测试)").Cells(i, "B")
- 值 = Sheets("Log(测试)").Cells(i, "C")
-
- With Sheets("分解明细")
- .Range(address) = 值
- End With
- Next
- Sheets("Log(测试)").Range("a2:c" & LLogTolNum).Clear
- End Sub
复制代码
|
|