VBA怎样判断当前活动的单元格是否在某一命名的区域?

2025-04-27 15:11:49
推荐回答(2个)
回答1:

Sub Test()
If Intersect(ActiveCell, Range("MyRange")) Is Nothing Then
MsgBox "当前单元格不在MyRange中"
Else
MsgBox "当前单元格在MyRange中"
End If
End Sub

回答2:

几句vba代码给你
dim Cel as Range
for each Cel in Range("MyRange")
if ActiveCell.Address=Cel.Address then msgbox ""
next