Push range against right screen edge
Actually this doesn't work.
I need to push a selected range against the right edge; that is the
right-most column of this selection has it's right edge against the right
screen edge.
I think the code I posted earlier seems to do a reasonable job.
RBS
"Jim Cone" wrote in message
...
RBS,
The following moves things around.
Hope it does what you want...
'----------------------
'Widens width of first column in window until last
'partially visible column in window is moved out of sight.
'Jim Cone - San Francisco, USA - September 11, 2005
Sub SizeToFit()
Dim rngVis As Excel.Range
Dim lngStart As Long
Dim lngStop As Long
Set rngVis = ActiveWindow.VisibleRange
lngStart = rngVis.Columns(rngVis.Columns.Count).Column
lngStop = rngVis.Columns(rngVis.Columns.Count).Column
Do Until lngStop = (lngStart - 1)
rngVis.Columns(1).ColumnWidth = rngVis.Columns(1).ColumnWidth + 1
Set rngVis = ActiveWindow.VisibleRange
lngStop = rngVis.Columns(rngVis.Columns.Count).Column
Loop
rngVis.Columns(1).ColumnWidth = rngVis.Columns(1).ColumnWidth - 0.5
Set rngVis = Nothing
End Sub
'-----------------------
"RB Smissaert"
wrote in message
...
Trying to figure out a way to push a selected range against the right edge
of the screen by inreasing the width of column A.
It thought a loop like this would do it:
Do Until lRangeRightCol _
rngVis.Cells(rngVis.Cells(1).Row, _
rngVis.Columns.count).Column
Columns(1).ColumnWidth = Columns(1).ColumnWidth + 1
Set rngVis = ActiveWindow.VisibleRange
DoEvents
Loop
Where lRangeRightCol is the right-most column of this range.
However it doesn't work. Column A gets wider and wider, but the loop
doesn't
exit.
Updating the screen doesn't help or more precisely doing
Application.ScreenUpdating = True
doesn't update the screen and maybe that is the trouble.
Any suggestions how to do this?
RBS
|