Hi,
I have a worksheet that contains data in columns A through ZY. I have the worksheet window split between columns M and N. All columns from N through ZY are titled with dates. I want to use a macro to hide certain columns from N through to a user selected column that is based on the date title. The user enters a date in a cell and runs the Macro and all columns from N through to that dated column are then hidden. The reason for hiding these columns is so that when the user drags from a column to the left of N, over the hidden columns, the hidden columns remain hidden, unlike if the window was simply split at column M-N.
When I "hide" the columns using the traditional drop down in Excel, it works fine as desired. Those columns never show up, regardless of where I drag my mouse.
The Macro below works like a charm in hiding the columns, but when I drag across the boundary over the hidden columns, the hidden columns reappear. It's like the VBA code for hiding columns is not the same as the basic "Hide" command found in the drop down in Excel. I've read/proven that "Veryhidden" does not work for columns.
What am I doing wrong?
Thx
Sub hidecolumns()
Dim X As Variant
X = Range("j2").Value
Columns("N").Columns(X).Select
Selection.Columns.Hidden = True
End Sub
I have a worksheet that contains data in columns A through ZY. I have the worksheet window split between columns M and N. All columns from N through ZY are titled with dates. I want to use a macro to hide certain columns from N through to a user selected column that is based on the date title. The user enters a date in a cell and runs the Macro and all columns from N through to that dated column are then hidden. The reason for hiding these columns is so that when the user drags from a column to the left of N, over the hidden columns, the hidden columns remain hidden, unlike if the window was simply split at column M-N.
When I "hide" the columns using the traditional drop down in Excel, it works fine as desired. Those columns never show up, regardless of where I drag my mouse.
The Macro below works like a charm in hiding the columns, but when I drag across the boundary over the hidden columns, the hidden columns reappear. It's like the VBA code for hiding columns is not the same as the basic "Hide" command found in the drop down in Excel. I've read/proven that "Veryhidden" does not work for columns.
What am I doing wrong?
Thx
Sub hidecolumns()
Dim X As Variant
X = Range("j2").Value
Columns("N").Columns(X).Select
Selection.Columns.Hidden = True
End Sub