Macro to move a cell to centre screen

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
 
G

Guest

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
 
V

Victor Delta

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top