2014-09-03 163 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 
相關問題