Macro to move a cell to centre screen

  • Thread starter Thread starter Victor Delta
  • Start date Start date
V

Victor Delta

I want to write a simple macro that will make a given cell (defined by the
contents of two other cells - i.e. row number and column number) move to
the centre of the screen (approximately).

Is there a simple way in which I can do this please? I can't find a function
to do it.

Thanks,

V
 
Try this:
Sub GotoSpecifiedCell()
'Assumes Range "A1" holds the row number &
'Range "A2" holds the column number
Application.Goto Reference:=Cells(Range("A1").value, Range("A2").value), _
Scroll:=True
With ActiveWindow
.SmallScroll Up:=(.VisibleRange.Rows.Count / 2), _
ToLeft:=(.VisibleRange.Columns.Count / 2)
End With
End Sub
 
Many thanks,

V


Charles Chickering said:
Try this:
Sub GotoSpecifiedCell()
'Assumes Range "A1" holds the row number &
'Range "A2" holds the column number
Application.Goto Reference:=Cells(Range("A1").value,
Range("A2").value), _
Scroll:=True
With ActiveWindow
.SmallScroll Up:=(.VisibleRange.Rows.Count / 2), _
ToLeft:=(.VisibleRange.Columns.Count / 2)
End With
End Sub
 
Back
Top