Selection.Areas.Count返回区域数,值为1时连续。
用union连接不相邻区域。
下面是一段示例代码:
fr01 = Selection.Cells(1).Row
fr02 = Selection.Cells(Selection.Cells.Count).Row
fr03 = Selection.Rows.Count
fc01 = Selection.Cells(1, 1).Offset(rowoffset:=fr03 - 1).Row
If fc01 <> fr02 Then
MsgBox ("该功能仅支持选中连续区域,请勿跳跃选中单元格")
Exit Function
Else