Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default sum height of selected rows

Is there an easy way to calculate the total height of selected rows?
eg, when I select 30 rows, where some or all of them have different heights,
how can I calculate the total height of the selection?

Even better, is there a VBA script for this?
Excel 2007

Thanks
--
Please, remove hyphens to contact me
--
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 913
Default sum height of selected rows

On Sun, 18 Jan 2009 06:27:00 -0800, geotso
wrote:

Is there an easy way to calculate the total height of selected rows?
eg, when I select 30 rows, where some or all of them have different heights,
how can I calculate the total height of the selection?

Even better, is there a VBA script for this?
Excel 2007

Thanks
--
Please, remove hyphens to contact me



If your selection is contiguous, i.e. without any gaps, you may try
this macro:

Sub height_of_selected_rows()
h = 0
For i = Selection.Row To Selection.Row + Selection.Rows.Count - 1
h = h + Cells(i, 1).height
Next i
MsgBox "The sum of heights of the selected rows is " & h
End Sub

Hope this helps / Lars-Åke
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default sum height of selected rows

Hi,

You do do this

For Each c In Selection
TotHeight = TotHeight + c.RowHeight
Next
MsgBox TotHeight

Mike

"geotso" wrote:

Is there an easy way to calculate the total height of selected rows?
eg, when I select 30 rows, where some or all of them have different heights,
how can I calculate the total height of the selection?

Even better, is there a VBA script for this?
Excel 2007

Thanks
--
Please, remove hyphens to contact me
--

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 913
Default sum height of selected rows

I don't think that we can assume that the selection is limited to one
column, especially as the OP writes that "30 rows" are selected.

Lars-Åke


On Sun, 18 Jan 2009 06:48:02 -0800, Mike H
wrote:

Hi,

You do do this

For Each c In Selection
TotHeight = TotHeight + c.RowHeight
Next
MsgBox TotHeight

Mike

"geotso" wrote:

Is there an easy way to calculate the total height of selected rows?
eg, when I select 30 rows, where some or all of them have different heights,
how can I calculate the total height of the selection?

Even better, is there a VBA script for this?
Excel 2007

Thanks
--
Please, remove hyphens to contact me
--


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default sum height of selected rows

"Mike H" wrote:

Hi,

You do do this

For Each c In Selection
TotHeight = TotHeight + c.RowHeight
Next
MsgBox TotHeight

Mike

I get a message "12779520" for my selection (an example of 32 rows). What
does that mean?

Thanks


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default sum height of selected rows

"Lars-Ã…ke Aspelin" wrote:

If your selection is contiguous, i.e. without any gaps, you may try
this macro:

Sub height_of_selected_rows()
h = 0
For i = Selection.Row To Selection.Row + Selection.Rows.Count - 1
h = h + Cells(i, 1).height
Next i
MsgBox "The sum of heights of the selected rows is " & h
End Sub

Hope this helps / Lars-Ã…ke

I've tried it and works like a charm!

Thank you very much
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Color alternate rows when after hiding selected rows Monk[_2_] Excel Worksheet Functions 6 June 7th 08 01:36 AM
How to create different height rows in different columns ezy Setting up and Configuration of Excel 1 August 17th 07 03:06 AM
hidden/0 height rows Scott Brooks Excel Discussion (Misc queries) 5 April 2nd 07 03:58 PM
HOW DO YOU FIX A ROWS HEIGHT melissa Excel Discussion (Misc queries) 1 April 27th 06 05:01 PM
Rows don't print at full height. BKL Excel Discussion (Misc queries) 0 December 5th 05 12:18 AM


All times are GMT +1. The time now is 05:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"