Reputation: 167
I'm having an issue unhiding columns using VBA. I've been using this link as a basis to try solving my issue, but it isn't working for me.
Macro to Hide/Unhide Columns in Excel
This is my code right now:
Public Sub a_view_calc_columns()
Dim calc as Worksheet
Dim rng as Range
Set calc = ThisWorkbook.Sheets("Calc")
Set rng = calc.Range("A:T")
rng.EntireColumn.Hidden = False
I've also tried:
rng.Column.EntireColumn.Hidden = False
And
With Columns("A:T")
If .EntireColumn.Hidden = True Then
.EntireColumn.Hidden = False
End If
End With
I'm using Excel 2016.
I should note that there will be data in columns A:T and that I'm manually hiding columns G & H to test the code.
Upvotes: 0
Views: 11210
Reputation: 84475
Here is a simple example
Option Explicit
Sub test()
With ActiveSheet
If .Columns("G:H").EntireColumn.Hidden Then
MsgBox "Hidden"
.Columns("G:H").EntireColumn.Hidden = False
Else
MsgBox "Those columns aren't hidden"
End If
End With
End Sub
Upvotes: 3