Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default VBA to center Selected Cell in Current Window

EagleOne,

Try a modivication of this:

'-------------------------------------

Dim rHot As Long
Dim cHot As Long

rHot = ActiveCell.Row
cHot = ActiveCell.Column

With ActiveWindow
If rHot Int(.VisibleRange.Rows.Count * 0.5) - 1 Then
.scrollRow = rHot - Int(.VisibleRange.Rows.Count * 0.5) + 1
End If
If cHot Int(.VisibleRange.Columns.Count * 0.5) - 1 Then
.ScrollColumn = cHot - Int(.VisibleRange.Columns.Count * 0.5) + 1
End If
End With

'------------------------------------

Steve Yandl



wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default VBA to center Selected Cell in Current Window

Thanks Steve!

"Steve Yandl" wrote:

EagleOne,

Try a modivication of this:

'-------------------------------------

Dim rHot As Long
Dim cHot As Long

rHot = ActiveCell.Row
cHot = ActiveCell.Column

With ActiveWindow
If rHot Int(.VisibleRange.Rows.Count * 0.5) - 1 Then
.scrollRow = rHot - Int(.VisibleRange.Rows.Count * 0.5) + 1
End If
If cHot Int(.VisibleRange.Columns.Count * 0.5) - 1 Then
.ScrollColumn = cHot - Int(.VisibleRange.Columns.Count * 0.5) + 1
End If
End With

'------------------------------------

Steve Yandl



wrote in message
.. .
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


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 Comment Over Selected Cell inthepickle Excel Programming 3 December 27th 06 03:58 PM
Macro to run relative to current selected cell MahD Excel Discussion (Misc queries) 3 December 11th 06 06:18 AM
ctrl-v paste a window shot rather than the selected text/cell Brian Excel Worksheet Functions 0 March 22nd 06 05:10 AM
a way to color the CURRENT row or cell when selected haneira Excel Programming 2 June 6th 05 10:23 AM
how can one obtain the current selected cell value Susan Hayes Excel Programming 3 December 14th 04 10:31 AM


All times are GMT +1. The time now is 11:02 PM.

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

About Us

"It's about Microsoft Excel"