首先你要使用在需要範圍內的數字:
'Removes formulas above the last line in the Auto Lease Data
Dim ALR As Long
Dim ALR2 As Range
With Sheets("Auto Lease Data")
ALR = .Range("A" & .Rows.Count).End(xlUp).Row
Set ALR2 = .Range(ALR -1 & ":" & ALR -1)
ALR2.select
End With
現在假設你要嘗試並獲得全範圍我就改成這樣:
'Removes formulas above the last line in the Auto Lease Data
Dim ALR As Long
Dim ALR2 As Range
With Sheets("Auto Lease Data")
ALR = .Range("A" & .Rows.Count).End(xlUp).Row
Set ALR2 = .Range("A1:J" & ALR -1)
ALR2.select
End With
這將選擇從A1到J列的所有內容,直到倒數第二行。將J更改爲最後一列。如果您要複製並粘貼它,將節省時間來定義最後一列。
如果要複製和過去的值回本身(刪除公式),那麼:
'Removes formulas above the last line in the Auto Lease Data
Dim ALR As Long
Dim ALR2 As Range
With Sheets("Auto Lease Data")
ALR = .Range("A" & .Rows.Count).End(xlUp).Row
Set ALR2 = .Range("A1:J" & ALR -1)
ALR2.value = ALR2.value
End With
要你在哪裏粘貼值? –
在同一張工作表上。謝謝。 – UnbrokenChain
「複製/粘貼」之前無需「選擇」。 [見此](http://stackoverflow.com/q/10714251/445425) –