- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 1# 藍天麗池 - Option Explicit
- Sub Ex()
- 'With 陳述式 : 一個物件或使用者自訂型態的名稱
- With Range("D6")
- .FormulaR1C1 = "=RC[-1]/2"
- If .Cells.End(xlDown).Row = Cells(Rows.Count, .Column).End(xlUp).Row Then
- '資料區的資料沒中斷有連續,可從上往下到資料區的最後一筆資料
- ' .Cells.End(xlDown) *** 有一點 .Cells 是 With物件的 Cells ***
- .AutoFill Destination:=Range(.Cells, .Cells.End(xlDown))
- Else
- '資料區的資料有空白資料,必需由工作表底部由下往上到資料區的最後一筆資料
- '** Cells(Rows.Count, .Column) ** -> Cells(工作表的列位總數, Range("D6")的欄位數)
- '** Cells這裡沒一點 . 是工作表的 Cells 不是Range("D6")的 Cells**
- '** 有一點 .Column 是Range("D6")的 欄位 **
- .AutoFill Destination:=Range(.Cells, Cells(Rows.Count, .Column).End(xlUp))
- End If
- End With
- End Sub
複製代碼 |
|