Im using this code to resize cell on click, to autofit text. Unfortunately, this code breaks filter and unfilitered data pops-up.
Does anyone have idea what could be done here so filter always remain the same until manually changed?
Does anyone have idea what could be done here so filter always remain the same until manually changed?
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static iRow As Long
Application.EnableEvents = True
If Target.Row = 1 Then
UsedRange.Rows.RowHeight = 12.75
Exit Sub
End If
If Not Intersect(Target, Range("D:D")) Is Nothing Then
If Target.Rows.Count > 1 Then Exit Sub
If iRow > 0 Then
Rows(iRow).RowHeight = 12.75
End If
iRow = Target.Row
Target.EntireRow.AutoFit
If Target.EntireRow.Height < 22 Then
Rows(iRow).RowHeight = 24.75
End If
End If
If Intersect(Target, Range("D:D")) Is Nothing Then
If Target.Rows.Count > 1 Then Exit Sub
If iRow > 0 Then
UsedRange.Rows.RowHeight = 12.75
End If
End If
Application.EnableEvents = True
End Sub