VBA to continously update row height as cell changes

karinfromsweden

New Member
Joined
Oct 30, 2018
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hey all,
Remember I did this years ago, but now I cant get it to work, nor find a similar question in the forum. I'm generating a list where the cell content change a lot from row to row depending on the user input. The list is mainly generated via validation lists, sometimes there's a lot of text, sometimes just a few words. What I need is a macro that works continuously, so if a longer value is selected in the list, the row should automatically get higher, but if its changed to a shorter value, the row should shrink.
Using the "Format > Autofit" doesn't work seamlessly, it "sticks" to one height, and if the cell changes to another size, the command has to be repeated. I want the macro to be running in the background and do this automatically.

Could anyone please help?

Many thanks in advance

/Karin
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hey all,
Remember I did this years ago, but now I cant get it to work, nor find a similar question in the forum. I'm generating a list where the cell content change a lot from row to row depending on the user input. The list is mainly generated via validation lists, sometimes there's a lot of text, sometimes just a few words. What I need is a macro that works continuously, so if a longer value is selected in the list, the row should automatically get higher, but if its changed to a shorter value, the row should shrink.
Using the "Format > Autofit" doesn't work seamlessly, it "sticks" to one height, and if the cell changes to another size, the command has to be repeated. I want the macro to be running in the background and do this automatically.


I guess it's something starting with

Private Sub Worksheet_SelectionChange(ByVal Target As Range) ...but then what?

/Karin again....
 
Upvote 0
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("F4:I2000")) Is Nothing Then
Target.Rows.AutoFit
Else
Range("F:F").Rows.AutoFit
Range("G:G").Rows.AutoFit
Range("I:I").Rows.AutoFit
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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