|
本帖最后由 li3617 于 2014-10-26 12:23 编辑
target.offset(0,4)=“=sum(F7:R[-1]C)”这段代码执行结果却是=sum('F7':F9)。请问这该怎么修改啊。麻烦各位帮忙修改下哈。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Dim N&, I&
Dim h As Integer
With Target
h = .Row
l = .Column
If Not Intersect(Columns(3), Target) Is Nothing And Target.Row >= 7 Then
Application.EnableEvents = False
I = 1
N = 7
Do
If Cells(N, 3) <> "" Then
Cells(N, 1) = I
I = I + 1
Else
Cells(N, 1) = ""
End If
N = N + 1
Loop Until N > Cells(Rows.Count, 3).End(3).Row
Application.EnableEvents = True
End If
If h > 7 And Target.Column = 5 Then
If Target.Offset(0, -3) = "小计" Then Exit Sub
If Target.Offset(0, -3) = "合计" Then Exit Sub
If Target.Offset(0, -3) = "直接费合计" Then Exit Sub
If Target.Offset(0, -3) = "其他辅助材料费" Then Exit Sub
If Target.Offset(0, 0) > 0 And Target.Offset(0, -1) > 0 Then
Target.Offset(0, 1) = "=RC[-1]*RC[-2]"
End If
End If
If h > 7 And Target.Column = 2 Then
If Target.Offset(0, 0) = "税金" Then
Target.Offset(0, 4) = "=sum(F7:R[-1]C)*8%" '请问这句代码为什么不对
End If
If Target.Offset(0, 0) = "合计" Then
Target.Offset(0, 4) = "=sum(F7:R[-1]C)" '请问这句代码为什么不对
End If
End If
End With
End Sub |
|