Consulting

Results 1 to 9 of 9

Thread: Rowheight plus a little bit more

  1. #1

    Rowheight plus a little bit more

    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.

    [VBA]
    Range("A1:Q" & (LastRow)).Select

    With Selection
    .RowHeight = 35
    End With
    [/VBA]

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

    But I want it to add say 5 more pixels.

    I have tried

    [VBA]
    Range("A1:Q" & (LastRow)).Select

    With Selection
    .RowHeight = .RowHeight * 2
    End With
    [/VBA]


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

    Any ideas?

  2. #2
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    228
    Location
    Quote Originally Posted by Thom
    I have tried

    [vba]
    Range("A1:Q" & (LastRow)).Select

    With Selection
    .RowHeight = .RowHeight * 2
    End With
    [/vba]


    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

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That won't work as each row might be a different height. Pick the first

    [vba]

    With Range("A1:Q" & (LastRow))
    .RowHeight = .Cells(1, 1).RowHeight * 2
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Hi Marshy

    Sadly it does not work for me!

  5. #5
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    228
    Location
    Quote Originally Posted by xld
    That won't work as each row might be a different height. Pick the first

    [vba]

    With Range("A1:Q" & (LastRow))
    .RowHeight = .Cells(1, 1).RowHeight * 2
    End With
    [/vba]
    Hi xld,

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

    Thanks,

    Marshybid

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by marshybid
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Quote Originally Posted by xld
    That won't work as each row might be a different height. Pick the first

    [vba]

    With Range("A1:Q" & (LastRow))
    .RowHeight = .Cells(1, 1).RowHeight * 2
    End With
    [/vba]
    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?

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    For Each oRow in Rows("1:" & LAstRow)
    oRow.RowHeight = oRow.RowHeight + 2
    Next oRow
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    Quote Originally Posted by xld
    [vba]

    For Each oRow in Rows("1:" & LAstRow)
    oRow.RowHeight = oRow.RowHeight + 2
    Next oRow
    [/vba]
    That seems to have done the trick! Wow, awesome.

    I set oRow as a Range by the way.

    Thanks so much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •