|
回复 1楼 chenyuanwen 的帖子
就是每次录入记录的时候要复制公式公式新麻烦,
给你个代码,复制到all的工作表代码里,
可以实现:
每次录入完进仓或出仓数量后,下一行自动生成公式
这个功能,你会发现爽呆呆的
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim k As Range, r%
r = Target.Row + 1
rr = Target.Row
If Target.Value = "" Then Exit Sub
If Range("b" & rr) = "" Then Exit Sub
If Target.Row < 3 Then Exit Sub
If Target.Column = 8 Or Target.Column = 11 Then
Range(ActiveSheet.Cells(r - 1, 1), ActiveSheet.Cells(r - 1, 30)).AutoFill Destination:=Range(ActiveSheet.Cells(r - 1, 1), ActiveSheet.Cells(r, 30)), Type:=xlFillDefault
Range("T" & r & ":Y" & r & "," & "a" & r & ":c" & r & "," & "e" & r & ":h" & r & "," & "k" & r & "," & "m" & r).ClearContents
Range("a" & r) = Range("a" & r - 1) + 1
End If
End Sub |
|