|
選択している範囲が1つの方形なら
こんなのでも善いかも?
Public Sub Test()
Dim i As Long
Dim lngScopeRowTop As Long
Dim lngScopeRowEnd As Long
Dim lngScopeColTop As Long
Dim lngScopeColEnd As Long
Dim rngTarget As Range
Dim blnContain As Boolean
'例としてブロックの範囲が"C5:F15"の場合の各Row、Column位置
lngScopeRowTop = 5
lngScopeRowEnd = 15
lngScopeColTop = 3
lngScopeColEnd = 6
Set rngTarget = Selection
With rngTarget
If lngScopeRowTop <= .Row _
And (.Row + .Rows.Count - 1) <= lngScopeRowEnd Then
If lngScopeColTop <= .Column _
And (.Column + .Columns.Count - 1) _
<= lngScopeColEnd Then
blnContain = True
End If
End If
End With
Set rngTarget = Nothing
If blnContain Then
MsgBox "1のメッセージ"
Else
MsgBox "2のメッセージ"
End If
End Sub
|
|