本帖最后由 cg1 于 2011-11-24 15:21 編輯 http://club.excelhome.net/thread-793123-1-1.htmlhttp://club.excelhome.net/thread-794039-1-1.html感謝上述兩貼的各位高手回答,現在總結下來(lái)無(wú)法取消已經(jīng)多選的單元格,因此用 VBA 編寫(xiě)了一段代碼用來(lái)反選
核心代碼如下:
'獲取已使用區域與被選定區域的差集
Function GetSetDifferentCells() As Range
Dim src As Range, sel As Range
Dim Result As Range
Dim cl As Range
Set src = ActiveSheet.UsedRange
Set sel = Application.Selection
Debug.Print sel.Address
For Each cl In src
Debug.Print 'current:' & cl.Address
If Not Result Is Nothing Then
Debug.Print 'result:' & Result.Address
End If
If Application.Intersect(cl, sel) Is Nothing Then
If Not Result Is Nothing Then
Set Result = Application.Union(Result, cl)
Else
Set Result = cl
End If
End If
Next cl
Set GetInvisibleCells = Result
GetInvisibleCells.Select
End Function
關(guān)于此主題請參考:
Excel中如何返回差集
http://www.access911.net/index.asp?u1=a&u2=72FABF1E17DCE9F3
實(shí)際軟件下載地址如下:
http://access911.net/csdn/FileDescription.asp?mdb=2011-11-24&id=49&mode=3
實(shí)現效果如下:
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請
點(diǎn)擊舉報。