Row height problem

chobanne

Active Member
Joined
Jul 3, 2011
Messages
269
Hello all,

I have a problem that i cant solve except manually in excell. So if someone know the easier way for this it will be very good for me. Some code or maybe something in formatting rows or something else

So i will explain.

I have one data validation cell A1. and one table from B1-E5
Every time when i choose another values in cell A1 i got another text in all cells in table B1-E5.
My table is formatted to fixed columns width, and text in cells is formatted as wrap, middle align, centar
Everything is good if text in all cells is not wider then column width, but IF it is longer, i must manually change row height because i cant see all text.

Is there a chance to fix row heights according to the cells with longest text in that rows. It must be applied every time when i change values in cell A1, otherwise it means nothing to me. And another thing i forgot to mention i dont need rows height to be lover then 15.

Thank you
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I think You have to insert a code to auto fit your column like below.


Try this code


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("Sheet1").UsedRange.EntireColumn.AutoFit
End Sub
 
Upvote 0
As I understand it you want to autofit the rows and that the driver of the change is Cell A1.

Try this in the Sheet module of the sheet.
Note: your previous thread hides rows, this will unhide any hidden rows.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("A1")) Is Nothing Then
        Application.EnableEvents = False
        
        Range("B1:E5").EntireRow.AutoFit
    
        Application.EnableEvents = True
    End If

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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