ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Do using range vs. row iteration? (https://www.excelbanter.com/excel-programming/316078-do-using-range-vs-row-iteration.html)

Ed

Do using range vs. row iteration?
 
I'd like to set the height of all my rows to a certain minimum height. At
the moment, the only thing I can make work is to iterate through every row:
For iRow = numRow To 2 Step -1
If Rows(iRow).RowHeight < 25.5 Then
Rows(iRow).RowHeight = 25.5
End If
Next iRow

Is there a faster way to do this using a range?

Ed



crispbd[_21_]

Do using range vs. row iteration?
 

this sets all rows in the active worksheet to 25.5

Cells.Select
Selection.rowheight = 25.

--
crispb
-----------------------------------------------------------------------
crispbd's Profile: http://www.excelforum.com/member.php...fo&userid=1088
View this thread: http://www.excelforum.com/showthread.php?threadid=27638


No Name

Do using range vs. row iteration?
 
hi
Range("A1", Range("A1").Offset(10, 255)).Select
Selection.RowHeight = 25.5

in this example i just selected a range 10 rows down from
A1 and 255 collumns(all). you will have to find out how to
select your range. the above rowheight command is pretty
instantanious.
regards

-----Original Message-----
I'd like to set the height of all my rows to a certain

minimum height. At
the moment, the only thing I can make work is to iterate

through every row:
For iRow = numRow To 2 Step -1
If Rows(iRow).RowHeight < 25.5 Then
Rows(iRow).RowHeight = 25.5
End If
Next iRow

Is there a faster way to do this using a range?

Ed


.


Jake Marx[_3_]

Do using range vs. row iteration?
 
Hi Ed,

Ed wrote:
I'd like to set the height of all my rows to a certain minimum
height. At the moment, the only thing I can make work is to iterate
through every row: For iRow = numRow To 2 Step -1
If Rows(iRow).RowHeight < 25.5 Then
Rows(iRow).RowHeight = 25.5
End If
Next iRow

Is there a faster way to do this using a range?


As others have noted, it will be much faster to set the row height on a
range than through iterating over the rows 1 by 1.

This command will set the row height to 25.5 for the entire used range of
the active Worksheet:

ActiveSheet.UsedRange.RowHeight = 35.5

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Ed

Only set if LESS THAN . . .
 
Thanks for the tips. I can do that. But sometimes with Word Wrap on, the
information in the row has already made the row more than 25.5. If I make
it "only" 25.5, I will cut off text. Using the iteration, I can check to
see if the row is less than that, and enlarge it if it is; it is left alone,
though, if it's already tall enough.

Ed

"Ed" wrote in message
...
I'd like to set the height of all my rows to a certain minimum height. At
the moment, the only thing I can make work is to iterate through every

row:
For iRow = numRow To 2 Step -1
If Rows(iRow).RowHeight < 25.5 Then
Rows(iRow).RowHeight = 25.5
End If
Next iRow

Is there a faster way to do this using a range?

Ed






All times are GMT +1. The time now is 08:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com