如果他们的价值是负数,我就能让我的宏能够清除细胞。 特别是,宏应清除列H到K中的所有负单元格,直到A列的最后一行。
我尝试了这个我在网上找到的代码,但我真的不知道如何将它扩展到第I列到第K列(仅适用于第H列)。
CREATE TRIGGER Recharge_trigger
AFTER INSERT ON Recharges
REFERENCING NEW AS N
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
UPDATE Balances SET Balance = Balance + N.Amount Where Uid = N.Uid AND Stid = N.Stid;
END
我尝试复制此代码,每次将ColNum#更改为9,10和11,但它不起作用。为什么呢?
答案 0 :(得分:0)
这应该有效:
' Get last row of col A...
Dim lastRow as long, r As Long, c As Long
Range("A1").select
lastRow = Cells.Find("*",SearchOrder:=xlByRows,SearchDirection:=xlPrevious).Row
For r = 2 To lastRow
For c = 8 To 11
If IsNumeric(Cells(r, c)) Then
If Cells(r, c) < 0 Then
Cells(r, c).ClearContents
End If
End If
Next
Next