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

setting the width & height of a cell

0 views
Skip to first unread message

Mike Johnson

unread,
Dec 26, 2001, 11:49:13 PM12/26/01
to
When you set the width & height of a cell in excel 2000
the standard unit of measure is ? / pixels. Is there a
formula that converts pixels to inches?

Harald Staff

unread,
Dec 27, 2001, 6:51:06 AM12/27/01
to
Hi Mike

No such measure as an inch, I'm afraid. The widht of one pixel on your
screen depends on your screen resolution and how large your screen is.
640x480 on a 21 inch monitor makes pretty large pixels...
When it comes to printing, this has to do with DPI (dots per inch) settings
and possible zoom ratio of both the printer and of Excels print menu. There
are just too many variables to convert "what is" into "what seen" and "what
printed" in a sensible way.

Excel cell width has to with "how many default characters visible in a
cell". See Help on this.

HTH. Best wishes Harald

Mike Johnson <mlj...@qwest.net> skrev i
news:251d01c18e91$d508cb50$3def2ecf@TKMSFTNGXA14...

Debra Dalgleish

unread,
Dec 27, 2001, 7:09:11 AM12/27/01
to
This is a variation on code posted at
which changes columns to a centimetre measurement:

' based on code from
' http://www.erlandsendata.no/english/vba/ws/setrowcolumnmm.htm

Sub SetColumnWidthInch(ColNo As Long, inWidth As Integer)
' changes the column width to inWidth
Dim w As Single
If ColNo < 1 Or ColNo > 255 Then Exit Sub
Application.ScreenUpdating = False
w = Application.InchesToPoints(inWidth)
While Columns(ColNo + 1).Left - Columns(ColNo).Left - 0.1 > w
Columns(ColNo).ColumnWidth = Columns(ColNo).ColumnWidth - 0.1
Wend
While Columns(ColNo + 1).Left - Columns(ColNo).Left + 0.1 < w
Columns(ColNo).ColumnWidth = Columns(ColNo).ColumnWidth + 0.1
Wend
End Sub

Sub SetRowHeightInch(RowNo As Long, inHeight As Integer)
' changes the row height to inHeight
If RowNo < 1 Or RowNo > 65536 Then Exit Sub
Rows(RowNo).RowHeight = Application.InchesToPoints(inHeight)
End Sub

Sub ChangeWidthAndHeightInch()
'This example macro shows how you can set the
'row height for row 3 and the column width for column C to 3.5 cm:
SetColumnWidthInch 2, 1
SetRowHeightInch 2, 1
End Sub

0 new messages