PDA

View Full Version : Rowheight plus a little bit more



Thom
06-09-2008, 07:23 AM
Hello all.

In the sheet I'm creating, I have a lot of data, so I've put the address all in one cell with the top line size 12 and the rest of the lines size 8 (they aren't as important).

However when I go to print it, the bottom is cut off. If I remove the fontsize formatting, it works fine.

So basically i want to get the current rowheight and just had a lilttle bit more on. But my code doesn't seem to want to do it.


Range("A1:Q" & (LastRow)).Select

With Selection
.RowHeight = 35
End With


That works as it should (set all the rows to 35).

But I want it to add say 5 more pixels.

I have tried


Range("A1:Q" & (LastRow)).Select

With Selection
.RowHeight = .RowHeight * 2
End With



I got this off the msdn but it does not work, nothing happens.

Any ideas?

marshybid
06-09-2008, 07:39 AM
I have tried


Range("A1:Q" & (LastRow)).Select

With Selection
.RowHeight = .RowHeight * 2
End With



I got this off the msdn but it does not work, nothing happens.

Any ideas?

I tried the code above and it worked fine. Doubled the size of all rows in worksheet.

Marshybid

Bob Phillips
06-09-2008, 07:44 AM
That won't work as each row might be a different height. Pick the first



With Range("A1:Q" & (LastRow))
.RowHeight = .Cells(1, 1).RowHeight * 2
End With

Thom
06-09-2008, 07:50 AM
Hi Marshy

Sadly it does not work for me! :(

marshybid
06-09-2008, 07:51 AM
That won't work as each row might be a different height. Pick the first



With Range("A1:Q" & (LastRow))
.RowHeight = .Cells(1, 1).RowHeight * 2
End With


Hi xld,

So I guess it only worked for me as all rows were originally the same height already??

Thanks,

Marshybid

Bob Phillips
06-09-2008, 08:01 AM
So I guess it only worked for me as all rows were originally the same height already??

Correct.

Like you at first I thought it would work, but Thom stated in post #1 that row 1 was 12 units, the rest 8, so I changed my row 1 height in my test and reproduced the problem. Once I reporduced it, figuring out why was stright-forward, the solution was then simple. Of course, he might want it twice the actual height of each row, in which case he will have to loop.

Thom
06-09-2008, 08:05 AM
That won't work as each row might be a different height. Pick the first



With Range("A1:Q" & (LastRow))
.RowHeight = .Cells(1, 1).RowHeight * 2
End With


THat worked on the top cell and also changed various cells down the page, in fact only the cells with one line of data.

This is bizarre.

So what in theory would your code be to change add a small amount of height to every cell/row in your worksheet?

Bob Phillips
06-09-2008, 08:10 AM
For Each oRow in Rows("1:" & LAstRow)
oRow.RowHeight = oRow.RowHeight + 2
Next oRow

Thom
06-09-2008, 08:27 AM
For Each oRow in Rows("1:" & LAstRow)
oRow.RowHeight = oRow.RowHeight + 2
Next oRow


That seems to have done the trick! Wow, awesome.

I set oRow as a Range by the way.

Thanks so much :bow: