Positioning an Excel display using VBA

一世执手 提交于 2020-01-14 17:54:56

问题


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


回答1:


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




回答2:


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


来源:https://stackoverflow.com/questions/29307782/positioning-an-excel-display-using-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!