2014-09-03 125 views
2

有人能告诉我如何让我的电子表格移动VBA中最后一行文本。使用VBA滚动到Excel中最后一行文本

目前我使用下面的代码:

Range("p65536").End(xlUp).Select 

这工作,但它也移动到特定的列。我想这样做,但保留屏幕上的当前列。

回答

1

试试这个代码:你想改变什么

ActiveSheet.Cells(ActiveSheet.Rows.Count, Selection.Column).End(xlUp).Select

+0

谢谢 - 尝试以下(其中有一个行数)不会出现移动工作表 [ReportingSheet] .Cells(finalRow,Selection.column).END(xlUp)。选择 – Michaelb88 2014-09-03 21:01:33

0

ScrollRow。如果你也想水平滚动,你可以设置ScrollColumn

Dim targetSheet As Worksheet 
Set targetSheet = ActiveSheet ' Refer to your sheet instead of ActiveSheet. 

targetSheet.Activate ' Make sure the worksheet is active to prevent errors. 

With targetSheet.Cells(targetSheet.Rows.Count, Selection.Column).End(xlUp) 
    .Select ' not required to change the focus/view 
    ActiveWindow.ScrollRow = .Row 
End With 
相关问题