返回列表 上一主題 發帖

[發問] 如何引用typename(selection)判定是否為定義範圍的儲存格位置呢?

[發問] 如何引用typename(selection)判定是否為定義範圍的儲存格位置呢?

本帖最後由 dechiuan999 於 2010-9-21 12:42 編輯

各位大大好:

  小弟對定義範圍,在應用上
仍無法上手。說明詳如附件

test.rar (4.49 KB)

If Not Intersect(Selection, [student]) Is Nothing Then

TOP

謝謝超級版主。

intersect有學過,卻
不懂得應用。
小弟真該打屁股了。
Sub aa()   
    Dim mSht As Worksheet
    Dim mRng As Range   
    Set mSht = Worksheets("test")
    With mSht
        If Not Intersect(Selection, [student]) Is Nothing Then
            If TypeName(Selection) = "Range" Then
                Set mRng = Selection
                MsgBox mRng.Address
            End If
        End If        
    End With   
  End Sub

感恩版主大大。

TOP

回復 3# dechiuan999
If Not Intersect(Selection, [student]) Is Nothing Then
            If TypeName(Selection) = "Range" Then

這兩行要對調 先判斷為 "Range"  再 判斷 Intersect(Selection, [student])

TOP

謝謝版主。

小弟真是越來越迷糊。
謝謝版主大大的糾正。

TOP

        靜思自在 : 道德是提昇自我的明燈,不該是呵斥別人的鞭子。
返回列表 上一主題