ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Re : Excel – Width of a Column and PointsToScreenPixelsX (https://www.excelbanter.com/excel-programming/274695-re-excel-%96-width-column-pointstoscreenpixelsx.html)

TKT-Tang

Re : Excel – Width of a Column and PointsToScreenPixelsX
 
Re : Excel – Width of a Column and PointsToScreenPixelsX

1. Say, set a worksheet column width to 50.
2. By clicking the right hand side border of the column in the
heading, it shows 355 pixels.
3. The method, PointsToScreenPixelsX, computes the column width to be
294 pixels.
4. Please enlighten upon the discrepancy as shown.

5. The following code may illustrate :-
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Msg As String
ActiveCell.ColumnWidth = 50
Msg = "The width of the selected cell may be " &
ActiveWindow.PointsToScreenPixelsX(ActiveCell.Widt h) & " pixels." &
Chr(10)
Msg = Msg & "However, by clicking the right hand side border in the
column heading," & Chr(10)
Msg = Msg & "it shows 355 pixels."
MsgBox Msg
End Sub

6. Regards.


All times are GMT +1. The time now is 12:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com