0
votes

In Excel 2003, tried this on Excel 2007 also, on a random chosen cell the user enters a number which represents pixels. I want to re-size the row which contains the cell, according to this number of pixels, but since Excel 2003 and 2007 are using points for row height, how do I convert pixels to points ?

I have used this formula (nr of pixels in cell ) * 0.75 and implemented as such in vba 6

Rows(RI).RowHeight = Cells(RI, ColumnIndex).Value * 0.75

Works best in most cases, but, I know it sounds really crazy, sometimes when this value is 5 or 15 or 25 or 35 or 45, maybe other numbers, the row height ends up re-sized to 6, 16, 26, 36, 46 piexels, simulating the fact that Excel does not have a correspondent in points for this values.

The same thing happens when I go to a row, right click on it, row height... feature, give an input of 4,5, 4.5 points = 5 px * 0.75, and sometimes the row is re-sized to 6 px.

Am I really crazy or did you encountered this phenomenon before ?

thank you for all your time,

kind regards,

radu

1

1 Answers

1
votes

You are not crazy, many of the numbers in Excel have no logic that I have discovered. However the following methods and property may help:

PointsToScreenPixelsX
PointsToScreenPixelsY
PixelsPerInch
InchesToPoints
CentimetersToPoints

I should add that the conversion from pixels to points is font and font size specific.