PC Review


Reply
Thread Tools Rate Thread

How do I make all rows 7,...23 exactly 8 pixels higher ?

 
 
Markus Obermayer
Guest
Posts: n/a
 
      9th Dec 2007
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 ?

Markus

 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      9th Dec 2007
Hi Markus:

Try this tiny macro:

Sub row_your_boat()
For i = 7 To 23
Rows(i).RowHeight = Rows(i).RowHeight + 8
Next
End Sub

--
Gary''s Student - gsnu2007b


"Markus Obermayer" wrote:

> 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 ?
>
> Markus
>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      9th Dec 2007
> 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.

Rick

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      9th Dec 2007
>> 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

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      9th Dec 2007
>> 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 ?

>
> Try this tiny macro:
>
> Sub row_your_boat()
> For i = 7 To 23
> Rows(i).RowHeight = Rows(i).RowHeight + 8
> Next
> End Sub


To be clear for the OP, your subroutine increases the RowHeight by 8 points,
not 8 pixels.

I do notice a slight discrepancy (not your fault, the system's font handler
is doing it) in that the default standard height for Arial - 10 Points is
12.75 points high; adding 8 to that should make the rows 20.75 points high,
but my system shows it becoming 20.25 points high instead.

Rick

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      9th Dec 2007
Odd... I replied to the OP's message which is cross-posted to two
newsgroups, but my message only picked up this newsgroup to reply to. This
is the first time I can recall this (a newsgroup being ignored in a reply)
ever happening... I wonder why?

Rick


"Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in
message news:ePOG%(E-Mail Removed)...
>> 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.
>
> Rick


 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      9th Dec 2007
> 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 ?


Here is some Windows-only code to resize rows which you pre-selected 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

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      9th Dec 2007
Okay, now I am really confused. I posted this message as a direct response
to the OP's message over in the microsoft.public.excel.programming newsgroup
and it never got posted there... instead, it just got posted over here. I
don't understand why. When I posted my response to Gary''s Student, it went
to both listed newsgroups as it should have; but the messages I posted to
the OP's initial posting only seems to go to this newsgroup. I really don't
understand why... does anyone have an explanation for this? Did I
accidentally change a setting or something?

Rick


"Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in
message news:%(E-Mail Removed)...
>> 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 ?

>
> Here is some Windows-only code to resize rows which you pre-selected 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
>


 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      9th Dec 2007
Rick,
For what it is worth...
I count six messages from you in the Misc group and only two in Programming
as responses to this post.
I am using Outlook Express as the news reader.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Rick Rothstein (MVP - VB)"
wrote in message
Okay, now I am really confused. I posted this message as a direct response
to the OP's message over in the microsoft.public.excel.programming newsgroup
and it never got posted there... instead, it just got posted over here. I
don't understand why. When I posted my response to Gary''s Student, it went
to both listed newsgroups as it should have; but the messages I posted to
the OP's initial posting only seems to go to this newsgroup. I really don't
understand why... does anyone have an explanation for this? Did I
accidentally change a setting or something?

Rick

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      9th Dec 2007
According to Micorsoft, in the site listed below, 6 points equals 8 pixels.
However, it seems to me that I read somewhere that Excel adjusts row height
and columns width based on the font used and screen resolution settings.
That means that if you expect to get a precision setting, forget it.

http://office.microsoft.com/en-us/ex...517241033.aspx

"Markus Obermayer" wrote:

> 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 ?
>
> Markus
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to size rows and columns in pixels rather than units Mark Stephens Microsoft Excel Programming 3 11th Jun 2008 02:32 PM
How do I make all rows 7,...23 exactly 8 pixels higher ? Markus Obermayer Microsoft Excel Programming 9 9th Dec 2007 10:55 PM
Colums/Rows different Pixels from one monitor to another - Excel 2 =?Utf-8?B?Sm9uTQ==?= Microsoft Excel Programming 0 12th Jul 2007 12:20 AM
How do you make pictures smaller? i.e. less pixels? Tango_and_Saucepans Digital Imaging and Photography 18 3rd Sep 2005 01:16 PM
A photo is in Word. How do I make that pic go from 300 pixels to . =?Utf-8?B?TmFuY3k=?= Microsoft Word Document Management 8 29th Jan 2005 02:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:41 AM.