Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Positioning an Excel display using VBA

Tags:

excel

vba

Using VBA in Excel 2013. I would like to position the active worksheet with a specific cell (eg "X25") in the upper left corner. I have tried selecting cells off the currently displayed area, .Select ("ZZ200"), and then reselecting my target cell. I don't seem to be able to control where the target cell is positioned. Suggestions

like image 433
Steve Avatar asked Mar 27 '15 18:03

Steve


People also ask

How do I change the position of an absolute chart in Excel?

1. Select the chart you that you will set absolute position, and click Kutools > Charts > Chart Tools > Set Absolute Position of Chart. 2. In the popping out dialog, specify the position that you will move the chart to, and click the Ok button.


2 Answers

Try this:

Application.Goto Range("X25"), Scroll:=True

This article has more information and options that you might find helpful:

https://msdn.microsoft.com/en-us/library/office/ff839232.aspx

like image 191
Lumigraphics Avatar answered Oct 21 '22 19:10

Lumigraphics


Try this. I actually got most of this code using the "record macro" feature. it's a pretty handy tool when you don't know how to do something

my_cell = "ZZ2200"  'change this to whatever you need
cell_row = Range(my_cell).Row
cell_col = Range(my_cell).Column

'moves to the top left corner
ActiveWindow.SmallScroll ToRight:=-9999
ActiveWindow.SmallScroll Up:=-99999

'moves to your active cell
ActiveWindow.ScrollRow = cell_row
ActiveWindow.ScrollColumn = cell_col

'selects your cell
Range(my_cell).Select
like image 1
andrew Avatar answered Oct 21 '22 17:10

andrew