返回列表 上一主題 發帖

如何顯示範圍中右下角儲存格位置

回復 1# enoch
  1. Option Explicit
  2. Sub Ex()
  3.     Dim Temp As Range
  4.     Set Temp = Range("A1:E10")
  5.     With Temp
  6.     'With Range("A1:E10")
  7.         MsgBox .Cells(1, 1).Address                             '右上角
  8.         MsgBox .Cells(1, .Columns.Count).Address                '左上角
  9.         MsgBox .Cells(.Rows.Count, 1).Address                   '右下角
  10.         MsgBox .Cells(.Rows.Count, .Columns.Count).Address      '左下角
  11.     End With
  12. End Sub
複製代碼

TOP

本帖最後由 GBKEE 於 2013-2-4 16:37 編輯

回復 3# enoch
.specialcells(xlcelltypelastcell) 可以傳回指定範圍最 又下角嗎 ?  
等同傳回UsedRange範圍最右下角
  1. Sub Ex()
  2.     With ActiveSheet
  3.         MsgBox .Cells.SpecialCells(xlCellTypeLastCell).Address
  4.         With .UsedRange
  5.             MsgBox .Cells(.Rows.Count, .Columns.Count).Address
  6.         End With
  7.     End With
  8. End Sub
複製代碼

TOP

        靜思自在 : 天上最美是星星,人生最美是溫情。
返回列表 上一主題