VB in Excel Moving screen
How can I get Excel to scroll so that a given cell, say f13, is the top left cell?
Sorry for the noob question. I'm used to Visual C++. Thanks.
# 1 Re: VB in Excel Moving screen
Use the Window object's SmallScroll and LargeScroll methods to move the pane. Excel VBA ie:
Public Sub TryIt()
Call ScrollToCell(Application.ActiveSheet, 13, 6)
End Sub
Public Sub ScrollToCell(oSheet As Worksheet, lRow As Long, lCol As Long)
Dim oWindow As Window
Set oWindow = oSheet.Application.ActiveWindow 'Get the sheet's window object.
oSheet.Cells(1, 1).Activate 'Move to upper left.
Call oWindow.SmallScroll(lRow - 1, 0, lCol - 1, 0) 'Scroll the pane.
oSheet.Cells(lRow, lCol).Activate 'Activate the target.
Set oWindow = Nothing
End Sub