返回列表 上一主題 發帖

[分享] 使用 SpecialCells 方法的迷思

[分享] 使用 SpecialCells 方法的迷思

本帖最後由 GBKEE 於 2011-11-21 12:01 編輯

如指定的範圍中的儲存格有隱藏時 此時使用到SpecialCells的方法
就會觸動到工作表的Worksheet_SelectionChange
ThisWorkbook 的 Workbook_SheetSelectionChange 兩程序
使用參數 xlCellTypeLastCell  
永遠是傳回  UsedRange 的範圍中最後一個 Cell,  你無法傳回 在一指定 的範圍中最後一個 Cell
  1. Sub Ex()
  2.     With ActiveSheet
  3.        .[A15] = "TEST"
  4.        .[H1] = "TEST"
  5.         MsgBox .[A:A].SpecialCells(xlCellTypeLastCell).Address
  6.         MsgBox .UsedRange.SpecialCells(xlCellTypeLastCell).Address
  7.         .[A15] = ""
  8.         .[A10] = "TEST"
  9.         MsgBox .[A:A].SpecialCells(xlCellTypeLastCell).Address
  10.         MsgBox .UsedRange.SpecialCells(xlCellTypeLastCell).Address
  11.    End With
  12. End Sub
複製代碼

        靜思自在 : 【為善競爭】人生要為善競爭,分秒必爭。
返回列表 上一主題