Hello,
I'm pretty sure there is a simple solution to this, but I'm struggling.
I would like a VBA code that is triggered by a change to the contents of the cell A2.
When A2 is changed, it will automatically AutoFit Row Height and AutoFit Column Width for the cells W7:AE42.
I thought this would work, but alas it hasn't.
Any help would be much appreciated.
I'm pretty sure there is a simple solution to this, but I'm struggling.
I would like a VBA code that is triggered by a change to the contents of the cell A2.
When A2 is changed, it will automatically AutoFit Row Height and AutoFit Column Width for the cells W7:AE42.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
' Check if the changed cell is B2
If Target.Address = "$B$2" Then
Application.EnableEvents = False '
Range("W7:AE42").Rows.AutoFit
Range("W7:AE42").Columns.AutoFit
' Re-enable events
Application.EnableEvents = True
End IfEnd Sub
I thought this would work, but alas it hasn't.
Any help would be much appreciated.