ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Moving the Active cell to the left of the screen (https://www.excelbanter.com/excel-programming/285667-moving-active-cell-left-screen.html)

Dave Bash

Moving the Active cell to the left of the screen
 
I am trying to move the active cell so that its column is displayed as
the leftmost column on my screen.

I have two sheets - one with a Titles across the top row and the
second with a list of those titles. I want to be able to double click
on the second sheet item, have it match the column on the first. This
part works fine. The issue is how to have the chosen title display in
the left most column of my screen.

Thanks.

My code:
__________________________________________________ ______________________________
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
If Target.Column = 2 And Target.Value < "" Then jumpToHist
Target.Value
End Sub

Sub jumpToHist(tgt As String)
On Error Resume Next
col = Application.Match(tgt, Worksheets("Hist
(2)").Range("Print_Titles"), 0)

With Sheets("Hist (2)")
.Activate
.Cells(1, col).Activate
End With
On Error GoTo 0

End Sub

Jim Rech

Moving the Active cell to the left of the screen
 
All you need is this:

Application.Goto Sheets("Hist (2)").Cells(col, 5), True

instead of this:

With Sheets("Hist (2)")
.Activate
.Cells(1, col).Activate
End With

--
Jim Rech
Excel MVP




All times are GMT +1. The time now is 11:18 AM.

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