Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default VBA statement "scroll active cell to center"???

Excel 2000

Is there any VBA statement or simple code to scroll the active cell to
the center of the window? (the active cell remains the same address)
(or even a toolbar button to do this?)

There are a number of VBA scrolling commands in the help, but they
seem to be of the sort that, e.g., "take Row #n and make it the
top/first row visible in the window." That doesn't seem to be very
useful directly, and one would seem to have to do a lot of
"calculating" to make such a command perform the desired function.

With rows, setting n = current row - 5 or so would probably be "good
enough," but for columns, because of their highly variable width, such
an approach would likely fail miserably much of the time.

Thanks in advance.

Fred Holmes
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default VBA statement "scroll active cell to center"???

Hi Fred:

Sub center_it()
Application.Goto reference:=ActiveCell, scroll:=True
With ActiveWindow
i = .VisibleRange.Rows.Count / 2
j = .VisibleRange.Columns.Count / 2
..SmallScroll Up:=i, ToLeft:=j
End With
End Sub
--
Gary''s Student - gsnu2007a


"Fred Holmes" wrote:

Excel 2000

Is there any VBA statement or simple code to scroll the active cell to
the center of the window? (the active cell remains the same address)
(or even a toolbar button to do this?)

There are a number of VBA scrolling commands in the help, but they
seem to be of the sort that, e.g., "take Row #n and make it the
top/first row visible in the window." That doesn't seem to be very
useful directly, and one would seem to have to do a lot of
"calculating" to make such a command perform the desired function.

With rows, setting n = current row - 5 or so would probably be "good
enough," but for columns, because of their highly variable width, such
an approach would likely fail miserably much of the time.

Thanks in advance.

Fred Holmes

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default VBA statement "scroll active cell to center"???

Works like a charm! Many thanks. Fred Holmes

On Fri, 16 Nov 2007 13:17:01 -0800, Gary''s Student
wrote:

Hi Fred:

Sub center_it()
Application.Goto reference:=ActiveCell, scroll:=True
With ActiveWindow
i = .VisibleRange.Rows.Count / 2
j = .VisibleRange.Columns.Count / 2
.SmallScroll Up:=i, ToLeft:=j
End With
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Center across selection" rather than "Merge cells" Elardus Excel Discussion (Misc queries) 10 November 6th 08 02:28 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
how do I change color of "active" cell to differentiate from rest devildog97 Excel Discussion (Misc queries) 9 May 1st 08 03:25 PM
Scroll Bar missing "Control" tab in "Format Properties" dialog box Peter Rooney Excel Discussion (Misc queries) 5 August 24th 06 05:36 PM
"outline active cell differently than other cells" terri Excel Discussion (Misc queries) 1 January 25th 06 08:26 PM


All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"