Row Height

snapper1969

Board Regular
Joined
Apr 3, 2008
Messages
122
Hi,

I have the following code that formats and sizes a range.

Sub FlexFormFormat()
'
' Keyboard Shortcut: Ctrl+w
'
Columns("C:C").Select
Selection.ColumnWidth = 7
Columns("D:D").Select
Selection.ColumnWidth = 50
Range("D10:E27").Select
With Selection
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
End With
Range("D10:E27").Select
Selection.RowHeight = 45
End Sub

Is it possible to change the row height only of the rows that need it to enable all the text in those to be visible.

Thx,

John
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Maybe something like this may work, but I can't test it at the moment:

Code:
rows("10:27").autofit

Hope that helps.
 
Last edited:
Upvote 0
Try:

Code:
Sub FlexFormFormat()
'
' Keyboard Shortcut: Ctrl+w
'
Columns("C:C").ColumnWidth = 7
Columns("D:D").ColumnWidth = 50
With Range("D10:E27")
    .VerticalAlignment = xlBottom
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .EntireRow.AutoFit
End With
End Sub

Hope it helps,

Dom
 
Upvote 0
Guys,

Thx for that, autofit works great. I had to unmerge columns d and e as that was causing a problem with the autofit.

Is there a way to select the range as the ending row will be different each time?.

Thx,

John
 
Upvote 0
Modifying the code you can use:

Code:
Sub FlexFormFormat()
'
' Keyboard Shortcut: Ctrl+w
'
LC = cells(rows.count,"D").end(xlup).row
Columns("C:C").ColumnWidth = 7
Columns("D:D").ColumnWidth = 50
With Range("D10:E" & LC)
    .VerticalAlignment = xlBottom
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .EntireRow.AutoFit
End With
End Sub
Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,214,563
Messages
6,120,248
Members
448,952
Latest member
kjurney

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top