|
こんなのどうでしょう。
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim sAdd As New Collection
Dim sVal As New Collection
Dim i As Integer
sAdd.Add Item:="A1:H50"
sAdd.Add "A51:H100"
sAdd.Add "A101:H150"
sAdd.Add "A151:H200"
sVal.Add "P1"
sVal.Add "P2"
sVal.Add "P3"
sVal.Add "P4"
For i = 1 To sAdd.Count
If Not Intersect(Target, Range(sAdd.Item(i))) Is Nothing Then
UserForm1.Label.Caption = sVal.Item(i)
Exit For
End If
Next
Set sAdd = Nothing: Set sVal = Nothing
End Sub
|
|