我需要检查表中的当前单元格是否在第一行。它必须检查它自己的表,而不仅仅是表。我找不到任何关于此的信息。使用公式可以吗?如果是这种情况,我想做一个特殊的操作。
答案 0 :(得分:2)
考虑:
Sub WhereIsTheActiveCell()
Dim EquivRange As Range, r As Range
Dim lo As ListObject
Dim nFirstRow As Long, nLastRow As Long
Set lo = ActiveSheet.ListObjects(1)
With lo
Set EquivRange = .DataBodyRange
nFirstRow = EquivRange.Row
nLastRow = EquivRange.Rows.Count + EquivRange.Row - 1
If ActiveCell.Row = nFirstRow Then
MsgBox "activecell is in the first data row of the table"
ElseIf ActiveCell.Row = nFirstRow - 1 Then
MsgBox "activecell is the the header row of the table"
End If
End With
End Sub
答案 1 :(得分:2)