View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jason Zischke Jason Zischke is offline
external usenet poster
 
Posts: 147
Default Setting columnwidths

NickHK

Thanks, that is just what I was looking for.

Jason

"NickHK" wrote:

Jason,
Something like this, converting from points to the units of ColumnWidth.
<From Help
One unit of column width is equal to the width of one character in the
Normal style
</From Help


Private Sub CommandButton1_Click()
Dim ColWidth As Single
Dim Factor As Single
Dim i As Long
'The range of columns you want to fit in the window
With Range("rngColumns")
ColWidth = ActiveWindow.UsableWidth / .Columns.Count
Factor = .Columns(1).Width / .Columns(1).ColumnWidth
For i = 1 To .Columns.Count
.Columns(i).ColumnWidth = ColWidth / Factor
Next
End With

End Sub

NickHK

"Jason Zischke" wrote in message
...
Dear NickHK

That sounds about that might work but how do do the column width in points

?

Jason

"NickHK" wrote:

Jason,
Depending what you are trying to achieve, Window.UsableWidth (in points)

may
be what you are after.
Then .Column.Width (in points) for each column that you wish to adjust.

NickHK

"Jason Zischke" wrote in

message
...
Hi all,

I've got one that has stumped me, I'm tring to set my column widths so
that
they fit to the window size however when using different screen sizes

and
different pixel sizes I can't get it working in all cases. I am

currently
using the function application.width to grab the window size, if

anyone
can
help me that would be greatly appreciated.

Jason Zischke