Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveWindow.ScrollColumn to the right?

Status
Not open for further replies.

ZenRaven

Programmer
Mar 13, 2007
84
US
I'm looking for something that functions like ActiveWindow.ScrollColumn but that scrolls so that the selected column is the rightmost column in the window instead of the left. Any suggestions?
 
I just re-read my post and realized that it could be seen as quite a silly request. Let me explain a bit further. I change the width of some dependent comboboxes "attached" to some columns at runtime based on user selections. When this selection process gets to the right of the screen, sometimes the column gets resized past the edge of the active window. Instead of making the user scroll each time this happens, I'd like for the resized column to be set as the rightmost column in the window. I tried a simple .select on the cell but that seems to still scroll relative to the leftmost functionality of .ScrollColumn
 
I'm just going to keep replying to myself for everyone's amusement, lol.

I tried this but it still seems to pull me to the left of the column of the new coordinates I specify

Code:
Dim iLeftColumn As Integer
Dim rLeftColumn As Range
Dim iTopRow As Integer
Dim rTopRow As Range
Dim NewLeft As Double
Dim NewTop As Double

iLeftColumn = ActiveWindow.ScrollColumn
Set rLeftColumn = Columns(iLeftColumn)
iTopRow = ActiveWindow.ScrollRow
Set rTopRow = Rows(iTopRow)

NewLeft = rLeftColumn.Left + _
  ((ActiveCell.Left + ActiveCell.Width) - _
  (rLeftColumn.Left + ActiveWindow.Width))
If NewLeft < 0 Then NewLeft = 0

NewTop = rTopRow.Top + _
  ((ActiveCell.Top + ActiveCell.Height) - _
  (rTopRow.Top + ActiveWindow.Height))
If NewTop < 0 Then NewTop = 0

'Debug.Print rLeftColumn.Left
'Debug.Print rTopRow.Top
'
'Debug.Print NewLeft
'Debug.Print NewTop

ActiveWindow.ScrollIntoView _
    Left:=NewLeft, Top:=NewTop, _
    Width:=NewLeft, Height:=NewTop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top