Set thisrng = Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column).End(xlUp))
For Each cell In thisrng
此代码将所选单元格作为上部,并下移到活动列中的最后一行。 我需要将我的第一个单元格定义为A2并转到最后一行 - 2
非常感谢! 亲切的问候!
答案 0 :(得分:2)
虽然您应该更改“Sheet1”作为工作表的名称,但这应该有效:
Set thisrng = Sheets("Sheet1").Range("A2:A" & (Cells(Rows.Count,1).End(xlUp).Row)-2)
答案 1 :(得分:0)
这应该有效:
Dim thisrng As Range
Dim TwoRowsFromTheBottom As Long
TwoRowsFromTheBottom = Columns("A").Rows.Count - 2
Set thisrng = ActiveSheet.Range(Cells(2, "A"), Cells(TwoRowsFromTheBottom, "A"))
您也可以将Columns("A").Rows.Count - 2
添加到Set thisrng .....