I'm trying to create a macro which will hide/unhide a specified range of columns. Adding a column within the named range isn't problematic, but when adding a column at the borders of this range - macro doesn't work. For example, AM:BF is the named range ("Furniture") in my sheet. I need to add a column BG which will also be hidden by the macro. Same story when adding a new column on the left border. Could you guide me how to improve the code so that the columns added at the borders of the range will also be hidden/unhidden?
With ThisWorkbook.Sheets("Sheet1").Range("Furniture").EntireColumn
.Hidden = Not .Hidden
End With
place the following in your worksheet code pane:
I've added a variable
RangeName
(of typeString
) that equals to the name of the Name Range = "Furniture".Code