I have a value on one sheet that when I change it, I would like it to hide a number of columns on another sheet.
This is what I have so far
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
If Target.Address = "$C$34" Then
i = Target.Value
Sheets("Cost Savings").Activate
ActiveSheet.Range("C:N").EntireColumn.Hidden = False
ActiveSheet.Range(Cells(1, i + 2), Cells(1, 14)).EntireColumn.Hidden = True
End If
End Sub
On Sheet1 - I have 12 columns "C to N". When I change the value of C34 on sheet2, then it should hide the 'remaining' number of columns on sheet1. i.e if I enter "3" into C34 on Sheet2, then columns C,D and E should remain visible, columns F - N should be hidden on Sheet1.
I am getting error code '1004': Application-defined or object-defined error. for the red line of code.
I've tried these alternatives
Range("F:N") works
Range(Cells(1, 6), Cells(1, 14)) doesn't work
Range(Columns(6), Columns(14)) doesn't work
I'ld appreciate any help anyone could offer on this.
Thanks in advance
Bookmarks