Excelme at work
New Member
- Joined
- Feb 7, 2018
- Messages
- 18
Hi there,
I recently created a calendar based spreadsheet with a drop down menu which lists, calendar months, and hides columns as necessary. Works perfectly.
However, I now need to share this document around so have protected all worksheets within, the problem then arises that if you select a month, you get the error message
Run time error 1004
Unable to set the hidden property of the range class.
The macro for the calendar is as follows;
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And Target.Row = 1 Then
Dim c As Range, rng
Dim mymonth, month_val
month_val = Range("d1").Value
mymonth = Month(month_val)
Set rng = Range("e3:NJ3")
For Each c In rng
If Month(c) = mymonth Then
c.EntireColumn.Hidden = False
Else
c.EntireColumn.Hidden = True
End If
Next c
End If
End Sub
Would anyone happen to have a suitable workaround?
I have unticked "locked" on the entire column range that could potentially be hidden.
As soon as I unprotect the worksheet, the drop down list functions as expected.
I recently created a calendar based spreadsheet with a drop down menu which lists, calendar months, and hides columns as necessary. Works perfectly.
However, I now need to share this document around so have protected all worksheets within, the problem then arises that if you select a month, you get the error message
Run time error 1004
Unable to set the hidden property of the range class.
The macro for the calendar is as follows;
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And Target.Row = 1 Then
Dim c As Range, rng
Dim mymonth, month_val
month_val = Range("d1").Value
mymonth = Month(month_val)
Set rng = Range("e3:NJ3")
For Each c In rng
If Month(c) = mymonth Then
c.EntireColumn.Hidden = False
Else
c.EntireColumn.Hidden = True
End If
Next c
End If
End Sub
Would anyone happen to have a suitable workaround?
I have unticked "locked" on the entire column range that could potentially be hidden.
As soon as I unprotect the worksheet, the drop down list functions as expected.