>> The height of the rows 7,..,23 is in a certain Excel sheet to low.
>>
>> How can I increase the height (for only these rows) by 8 pixels ?
>>
>> Or more general: If I mark rows n,....,m
>> How can I make them x pixels (resp y millimeter) higher ?
>
> This should work for the general case. Select the rows you want to change
> and then run (Alt+F8) this macro...
>
> Sub IncreaseRowHeightsInPixels()
> Dim R As Range
> Dim Answer As Double
> Answer = InputBox("How may pixels higher do you want?")
> For Each R In Selection.Rows
> R.RowHeight = R.RowHeight + Answer * 0.75
> Next
> End Sub
>
> The 0.75 Pixels to Points conversion factor was obtained by calculation
> using the information at this web page...
>
> http://office.microsoft.com/en-us/ex...346241033.aspx
>
> after opening up the "How is row height measured?" link at the bottom of
> the page. I tried setting the spreadsheet to different values and it seems
> to work. However, it is possible that there is a dependency on the
> screen's font size (dpi) setting (at least in the Windows world) since the
> 96 in the "1-inch to 96-pixel" equivalency looks suspiciously like the 96
> dpi setting which is the standard for Windows (but which can be customized
> via the Display Panel). If you are willing to work in Points directly,
> simply remove the 0.75 multiplication factor and change the prompt in the
> InputBox function call to say Points instead of Pixels.
Okay, yes, the conversion factor **is** dependent on the DPI setting (if you
are using Windows). Here is the Windows code to resize your selected rows by
a specified number of pixels. Copy/paste the following code into your code
window and then run (Alt+F8) the IncreaseRowHeightsInPixels subroutine from
your spreadsheet after selecting the rows you want to increase by the number
of pixels you will specify when asked...
Private Declare Function GetDC Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hDC As Long, ByVal nIndex As Long) As Long
Private Declare Function ReleaseDC Lib "user32" _
(ByVal hwnd As Long, ByVal hDC As Long) As Long
Private Const LOGPIXELSY = 90 'Pixels/inch in Y
'A point is defined as 1/72 inches
Private Const POINTS_PER_INCH As Long = 72
'The size of a pixel, in points
Public Function PointsPerPixel() As Double
Dim hDC As Long
Dim lDotsPerInch As Long
hDC = GetDC(0)
lDotsPerInch = GetDeviceCaps(hDC, LOGPIXELSY)
PointsPerPixel = POINTS_PER_INCH / lDotsPerInch
ReleaseDC 0, hDC
End Function
Sub IncreaseRowHeightsInPixels()
Dim R As Range
Dim Answer As Double
Answer = InputBox("How may pixels higher do you want?")
For Each R In Selection.Rows
R.RowHeight = R.RowHeight + Answer * PointsPerPixel
Next
End Sub
Rick