我试图通过VBA在Excel 2013中确定ActiveCell是不是只在任何表中,而是在特定的表中.
下面是代码,但只检测ActiveCell在任何表中.注释掉的行是我正在寻找的,但显然它不起作用.
... Set rng = Intersect(.EntireRow, ActiveCell.ListObject.DataBodyRange) 'Set rng = Intersect(.EntireRow, ActiveCell.ListObjects("myTable").DataBodyRange) On Error GoTo 0 If rng Is Nothing Then MsgBox "Please select the cell of a row within the consensus input table.", vbCritical, "Delete Evaluator" Else ...
有关正确语法的任何建议吗?
谢谢!
要测试ActiveCell是否在Table1的主体中:
Sub qwerty() If Intersect(ActiveCell, ActiveSheet.ListObjects("Table1").DataBodyRange) Is Nothing Then MsgBox "activecell not in Table1" Else MsgBox "activecell in Table1" End If End Sub