ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   left align active column/cell in window (https://www.excelbanter.com/excel-programming/393026-left-align-active-column-cell-window.html)

NJS

left align active column/cell in window
 
Hi All,
does anyone know how I can set the column of the active cell to be leftmost
in the window?
When I activate a cell I need to see a specific range of columns starting
from the active one.
thank you,


Tom Ogilvy

left align active column/cell in window
 
Right click on the sheet tab and select view code.

in the dropdowns at the top of the resulting module select Worksheet in the
left dropdown and SelectionChange in the right dropdown (this is the default,
so they may already be selected).

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

will be in the module. Place this code between the entries

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveWindow.ScrollColumn = Target(1).Column
End Sub

--
Regards,
Tom Ogilvy


"NJS" wrote:

Hi All,
does anyone know how I can set the column of the active cell to be leftmost
in the window?
When I activate a cell I need to see a specific range of columns starting
from the active one.
thank you,


Incidental

left align active column/cell in window
 
Hi NJS

You could try something like the code below should help you out

[AA1].Activate
ColNumber = ActiveCell.Column
ActiveWindow.ScrollColumn = ColNumber

S


Mike H

left align active column/cell in window
 
Or to put the active cell in the top left corner

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.GoTo ActiveCell, True
End Sub

Mike
"NJS" wrote:

Hi All,
does anyone know how I can set the column of the active cell to be leftmost
in the window?
When I activate a cell I need to see a specific range of columns starting
from the active one.
thank you,


Rick Rothstein \(MVP - VB\)

left align active column/cell in window
 
does anyone know how I can set the column of the active cell to be
leftmost
in the window?
When I activate a cell I need to see a specific range of columns starting
from the active one.


After you activate the cell, execute this...

ActiveWindow.ScrollColumn = ActiveCell.Column
ActiveWindow.ScrollRow = ActiveCell.Row

Rick


NJS

left align active column/cell in window
 
Excellent! thanks Tom (ScrollColumn was the property I was looking for)
cheers.

"Tom Ogilvy" wrote:

Right click on the sheet tab and select view code.

in the dropdowns at the top of the resulting module select Worksheet in the
left dropdown and SelectionChange in the right dropdown (this is the default,
so they may already be selected).

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

will be in the module. Place this code between the entries

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveWindow.ScrollColumn = Target(1).Column
End Sub

--
Regards,
Tom Ogilvy


"NJS" wrote:

Hi All,
does anyone know how I can set the column of the active cell to be leftmost
in the window?
When I activate a cell I need to see a specific range of columns starting
from the active one.
thank you,



All times are GMT +1. The time now is 08:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com