filmov
tv
Excel VBA: A click to extend the column width automatically
Показать описание
In the short video I share a simple VBA procedure to extend the column width automatically by clicking a cell in target range. With the feature we may improve our excel user use experiences
VBA code Lines:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
Columns("D:N").ColumnWidth = ActiveSheet.Cells(2, 1)
If Not Intersect(ActiveCell, Columns("D:N")) Is Nothing Then ActiveCell.ColumnWidth = ActiveSheet.Cells(2, 2)
Application.ScreenUpdating = True
End Sub
Or from my Blog website you may find and copy the VBA codes:
- Other Links:
VBA code Lines:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
Columns("D:N").ColumnWidth = ActiveSheet.Cells(2, 1)
If Not Intersect(ActiveCell, Columns("D:N")) Is Nothing Then ActiveCell.ColumnWidth = ActiveSheet.Cells(2, 2)
Application.ScreenUpdating = True
End Sub
Or from my Blog website you may find and copy the VBA codes:
- Other Links: