I think pixels/inch varies by display.
Perhaps you can adapt this:
Sub MakeSquareCells()
' shg 2006
' for my LaserJet:
Const fHScal As Single = 1.08
Const fVScal As Single = 0.99
Dim fPts As Single
Dim fCnv As Single
Dim sUnits As String
Dim r As Range
sUnits = LCase(Application.InputBox(Prompt:="Inches (inch) or millimeters (mm)?", _
Title:="Units?", _
Default:="inch", _
Type:=2))
If sUnits <> "inch" And sUnits <> "mm" Then Exit Sub
fPts = Application.InputBox(Prompt:="Cell size, in " & sUnits & "?", _
Title:="Size?", _
Default:="1", _
Type:=1)
fCnv = IIf(sUnits = "inch", 72, 72 / 25.4)
fPts = fCnv * fPts ' convert to points
If fPts < 0.01 Or fPts > 409 Then Exit Sub
Set r = ActiveWindow.RangeSelection
SquareCells r, fPts, fHScal, fVScal
MsgBox Title:="SquareCells", _
Prompt:=Format(fPts / fCnv, "0.000") & " (Target size, " & sUnits & ")" & vbLf & _
Format(r.Columns(1).Width / fCnv, "0.000") & " (Actual width)" & vbLf & _
Format(r.Rows(1).Height / fCnv, "0.000") & " (Actual height)" & vbLf & _
Format(r.Columns(1).Width / r.Rows(1).Height, "0.000") & " (Aspect)"
End Sub
Function SquareCells(r As Range, _
ByVal fPts As Single, _
Optional fHScal As Single = 1, _
Optional fVScal As Single = 1) As Single
' Sets all cells in r to be approximately fPts x fPts (points)
' Returns the actual aspect H/W
' fHScal and fVScal compensate for the printer; obtain by measuring
' For scale factors:
' Make a sheet with cells of nominal size (e.g., 1") and scale factors set to 1
' Measure the horizontal size as printed; aay it's 1.03 inches. Use 1.03 as fHScal
' Ditto for vertical size and fVScal
Dim i As Long
Dim sDim As String
r.Select
For i = 1 To 4
r.Columns.ColumnWidth = r.Columns(1).ColumnWidth / r.Columns(1).Width * fPts / fHScal
r.Rows.RowHeight = fPts / fVScal
Next i
SquareCells = r.Columns(1).Width / r.Rows(1).Height
End Function
Bookmarks