首先你要使用在需要范围内的数字:
'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) –