精華區beta Office 關於我們 聯絡資訊
[例一] Range([A1], [A65536].End(xlUp)) [例二] lastcol = [A1].End(xlToRight).Column lastrow = [A65536].End(xlUp).Row Range([A1], Cells(lastrow, lastcol)).Select [例三] Range([A1], Cells.SpecialCells(xlCellTypeLastCell)).Select 註: xlLastCell 亦可 見#19a5gqHb [例四] [A1].CurrentRegion.Select [例五] Activesheet.UsedRange.Select [例六] Columns(1).Find(What:="*", LookIn:=xlValues, SearchDirection:=xlPrevious).Row --此法不同,原提問如下-- 當我要copy部分資料時常這樣寫: Range("A6:K" & Range("a65536").End(xlUp).Row).Copy 但是當a欄底下的儲存格看似空白,但有函公式存在時, 無法選取到有資料的列為止,而會選取到所有函公式的列, 如a6:a100有公式:=if(b6="","",$c$1),雖然有資料的列只到a10, 但還是會選到a100,請問除了改為Range("b65536")…. 有更好的方式嗎?能否把含公式但無數值的儲存格視為空白? [例七] lastRow = 65536 - Application.CountBlank(Columns(1))[A1].Resize(lastRow).Copy [例八] With ThisWorkbook.Sheets(1) Set rLastCell = .Cells.Find(What:="*", After:=[A1], _ SearchDirection:=xlPrevious) End With -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: [一~七] http://gb.twbts.com/index.php/topic,768.0.html http://gb.twbts.com/index.php/topic,315.0.html http://gb.twbts.com/index.php/topic,584.0.html [八] #19xSnqw- [三註] #19a5gqHb