View Full Version : Solved: Active cell display
Hi
Does anyone have a code to make the active cell in a worksheet display in the centre or on the left of the screen?
Regards & thank you
Blade Hunter
06-07-2010, 11:48 PM
activecell.Activate
Bob Phillips
06-08-2010, 01:08 AM
activecell.Activate
Surely, by definition, the activecell is already activated?
Bob Phillips
06-08-2010, 01:12 AM
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim posRow As Long
Dim posColumn As Long
posRow = ActiveCell.Row
posColumn = ActiveCell.Column
With ActiveWindow
If posRow > Int(.VisibleRange.Rows.Count * 0.5) - 1 Then
.ScrollRow = posRow - Int(.VisibleRange.Rows.Count * 0.5) + 1
End If
If posColumn > Int(.VisibleRange.Columns.Count * 0.5) - 1 Then
.ScrollColumn = posColumn - Int(.VisibleRange.Columns.Count * 0.5) + 1
End If
End With
End Sub
This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.
DEEP :bow:
Thank you xld.That works a treat.
Thank you all for the info.
regards
Blade Hunter
06-08-2010, 04:32 PM
Surely, by definition, the activecell is already activated?
It worked for me :). Even if it didn't you could have done something like:
activecell.Offset(0,0).select
Edit, Having now read xld's code I understand the problem a bit better.
This is what I don't get. Select a cell then use the scroll bars to put it off screen
in the debug window type activecell.activate
The Screen centres
Try and do that in the selection change event and nothing happens.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.