Standard column width in points...

C

Charlotte E.

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
 
P

Peter T

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?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top