VBA to center Selected Cell in Current Window

E

EagleOne

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
 

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