Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Standard column width in points...

6 views
Skip to first unread message

Charlotte E.

unread,
May 22, 2013, 3:35:01 AM5/22/13
to
Hi,


I can read the standard column width of a sheet with
ActiveSheet.StandardWidth

...but this gives me the width in chars....

How to get the standard columnwidth in points?


TIA,

CE

Peter T

unread,
May 24, 2013, 12:39:37 PM5/24/13
to
More specifically StandardWidth returns the number of 'standard' characters
of the "Normal" font that will fit in the column (by defaullt 8 with some
padding)

You could try something like this

Sub test()
MsgBox StdWidthToPoints(ActiveSheet) & " points"
End Sub

Function StdWidthToPoints(ws As Worksheet)
Dim sngOldW As Single
sngOldW = -1
If ws.Range("A:A").ColumnWidth <> ws.StandardWidth Then
sngOldW = ws.Range("A1").ColumnWidth
' will error if protected
ws.Range("A:A").ColumnWidth = ws.StandardWidth
End If
StdWidthToPoints = ws.Range("A1").Width
If sngOldW >= 0 Then
ws.Range("A:A").ColumnWidth = sngOldW
End If
End Function

Regards,
Peter T

0 new messages