View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] EagleOne@discussions.microsoft.com is offline
external usenet poster
 
Posts: 391
Default VBA to center Selected Cell in Current Window

2003/2007

What VBA code can I use to center the selected cell in the current window?


Programmatically, I have selected a cell and that cell is in the current window for the 500+ sheets
in a workbook.

BTW, the code below is from Automation of Excel from Access. Therefore, the standard Excel objects
Application, ActiveSheet, Acvtiveworkbook are oSht, oWbk1 & oXL respectively.

The code I used is next:

For Each oSht In oWbk1.Worksheets
oSht.Activate
oXL.ActiveWindow.View = xlNormalView
oXL.ActiveWindow.Zoom = 75
oSht.Columns.AutoFit
oSht.ActiveCell.Select
oSht.Protect _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
AllowSorting:=True, _
AllowFiltering:=True, _
AllowUsingPivotTables:=True

Next oSht

I would like to have that selected cell be in the middle of that screen no matter how many rows
there are in the worksheet.

TIA EagleOne