|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
单元格颜色、内容随方向键移动.rar
(33.5 KB, 下载次数: 5)
'修改了一下
Option Explicit
Private Type pos
x As Long
y As Long
End Type
Dim lastcolor, lastvalue, p As pos
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo errmsg
If Target.Count > 1 Then Exit Sub
With p
If .x > 0 Then
Target.Interior.ColorIndex = lastcolor
Target = lastvalue
Cells(.x, .y).Interior.ColorIndex = xlNone
Cells(.x, .y) = vbNullString
.x = Target.Row: .y = Target.Column
Else
If Target.Interior.ColorIndex <> xlNone Or Len(Target) > 0 Then
lastcolor = Target.Interior.ColorIndex
lastvalue = Target
.x = Target.Row: .y = Target.Column
End If
End If
End With
Exit Sub
errmsg:
End Sub
Sub reset()
p.x = 0
End Sub
|
|