I created a simple macro to hide/unhide columns in Excel (attached below). It works fine, however, when adding a column within the range of columns in the macro, the last column supposed to be hidden remains unhidden. To make myself clear: The range of columns in macro is AM:BF. When I need to add a column within this range, the column BF stays unhidden. Could you help me how to improve the code so that the initial range of columns would stay hidden as well as the added one?
With Columns("AM:BF")
If .EntireColumn.Hidden = True Then
.EntireColumn.Hidden = False
Else
.EntireColumn.Hidden = True
End If
End With