|
楼主 |
发表于 2019-11-10 10:22
|
显示全部楼层
下面的选定改变是只要改变就触发了?整个宏删除对表的影响不大吗?,下面宏的大意是?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim r As Long
Dim temps As String
Dim l As Long
On Error Resume Next
If ecgx = 1 Then Exit Sub
ecgx = 1
If ActiveSheet.Name <> "凭证" Then
dqrow = 0
dqcol = 0
ecgx = 0
Exit Sub
End If
rrrrrrrrr = dqrow '记录之前行
r = rrrrrrrrr
l = dqcol
If r < 5 Then
dqcol = ActiveCell.Column
dqrow = ActiveCell.Row
rrrrrrrrr = dqrow '记录之前行
r = rrrrrrrrr
If dqrow < 5 Then
ecgx = 0
Unload kmxxfrm
Exit Sub
End If
If dqcol = 7 Or dqcol = 10 Then
ecgx = 0
jckmbm
' pzsr dqrow
ecgx = 1
End If
Sheets("凭证").Unprotect Password:="1"
temps = "g" & dqrow & ":" & "q" & dqrow
Range(temps).Interior.ColorIndex = 38
Sheets("凭证").Protect Password:="1"
If kmxxfrm.Visible = True Then
Call skmxx
End If
ecgx = 0
Exit Sub
Else
ecgx = 0
jckmbm '检查科目编码
ecgx = 1
temps = "g" & dqrow & ":" & "q" & dqrow
Sheets("凭证").Unprotect Password:="1"
Range(temps).Interior.ColorIndex = xlNone
dqcol = ActiveCell.Column
dqrow = ActiveCell.Row
If dqrow < 5 Then
Sheets("凭证").Protect Password:="1"
ecgx = 0
Unload kmxxfrm
Exit Sub
End If
' If dqcol = 7 Or dqcol = 10 Then
' pzsr dqrow
' End If
If Cells(r, 13) <> "" And Cells(r, 15) <> "" Then Cells(r, 16) = VBA.Round(Cells(r, 13) / Cells(r, 15), 4)
If Cells(r, 14) <> "" And Cells(r, 15) <> "" Then Cells(r, 16) = VBA.Round(Cells(r, 14) / Cells(r, 15), 4)
temps = "g" & dqrow & ":" & "q" & dqrow
Range(temps).Interior.ColorIndex = 38
Sheets("凭证").Protect Password:="1"
If kmxxfrm.Visible = True Then
Call skmxx
End If
End If
ecgx = 0
dqcol = ActiveCell.Column
dqrow = ActiveCell.Row
End Sub |
|