下面是程式碼分享
Sub 交集()
Dim sr As Range, sr2 As Range 申明資料型別變數
Dim ch As Range, ch2 As Range
For Each sr In Range("a2:a9") 迴圈區域單元格
If sr.Value = "劉能" Then 條件判斷
Set ch = sr.EntireRow 把單元格物件賦給變數
Exit For 退出迴圈
End If 結束條件判斷
Next 條件達到退出迴圈
For Each sr2 In Range("b1:g1") 迴圈區域單元格
If sr2.Value = "3月" Then 條件判斷
Set ch2 = sr2.EntireColumn 把單元格物件賦給變數
Exit For 退出迴圈
End If 結束條件判斷
Next 條件完成退出迴圈
Intersect(ch, ch2).Select 選擇兩個相交單元格區域
End Sub