John Caines
Well-known Member
- Joined
- Aug 28, 2006
- Messages
- 1,155
- Office Version
- 2019
- Platform
- Windows
Hello All.
I found a bit of code here to hide /toggle some rows which was;
Great!! Works fine,,,,so, on the same sheet I want to also toggle some columns at the end (Right hand side) of my worksheet.
So, I think's to myself,,, let's just replace the words 'Row' With 'Column' from the code above.
So I've tried;
Problem,,I get a Run-time error '1004'....???
Unable to set Hidden property of the Range clas
?? Not a clue what this means.
\The line that is highlighted yellow on the debug is
As a note,, the bottom of my sheet from Row 38 I have hidden (Don't want to show all cells below this row as none are being used). Also I have hidden the columns from Column AV onwards, as I don't want to see any columns after AU.
So not sure if this has something to do with it/ sub not working??
Can anybody help me out here? I'm sure it's something quite easy, but it's only easy when you know how!
I've tried googling,,, what a mess,,, sent all over the net, not really sure what I'm looking at as everyone has slightly different problems.
Hope someone can help
Many thanks
JohnC
I found a bit of code here to hide /toggle some rows which was;
Code:
Sub ToggleRows()
Rows("23:37").Select
If Selection.EntireRow.Hidden = True Then
Selection.EntireRow.Hidden = False
Else: Selection.EntireRow.Hidden = True
End If
End Sub
So, I think's to myself,,, let's just replace the words 'Row' With 'Column' from the code above.
So I've tried;
Code:
Sub ToggleColumns()
Columns("AN:AT").Select
If Selection.EntireColumn.Hidden = True Then
Selection.EntireColumn.Hidden = False
Else: Selection.EntireColumn.Hidden = True
End If
End Sub
Problem,,I get a Run-time error '1004'....???
Unable to set Hidden property of the Range clas
?? Not a clue what this means.
\The line that is highlighted yellow on the debug is
Code:
: Selection.EntireColumn.Hidden = True
As a note,, the bottom of my sheet from Row 38 I have hidden (Don't want to show all cells below this row as none are being used). Also I have hidden the columns from Column AV onwards, as I don't want to see any columns after AU.
So not sure if this has something to do with it/ sub not working??
Can anybody help me out here? I'm sure it's something quite easy, but it's only easy when you know how!
I've tried googling,,, what a mess,,, sent all over the net, not really sure what I'm looking at as everyone has slightly different problems.
Hope someone can help
Many thanks
JohnC