jimmisavage
Board Regular
- Joined
- Jun 28, 2017
- Messages
- 130
I have a simple VBA to hide and unhide cells based in a formula in AF1
This does the job but there is also an instance when AF1 can be #N/A which throws an error because i've not told it that would be an option.
I've tried adding an option of below but it doesn't seem to recognise the #N/A
How would I combat this?
Many thanks
Jimmi
Code:
If Range("AF1") = "Non Commercial" Then
Columns("P").EntireColumn.Hidden = True
Columns("Q").EntireColumn.Hidden = True
Columns("R").EntireColumn.Hidden = True
End If
If Range("AF1") = "Commercial" Then
Columns("P").EntireColumn.Hidden = False
Columns("Q").EntireColumn.Hidden = False
Columns("R").EntireColumn.Hidden = False
End If
This does the job but there is also an instance when AF1 can be #N/A which throws an error because i've not told it that would be an option.
I've tried adding an option of below but it doesn't seem to recognise the #N/A
Code:
If Range("AF1") = "#N/A" Then
Columns("P").EntireColumn.Hidden = False
Columns("Q").EntireColumn.Hidden = False
Columns("R").EntireColumn.Hidden = False
End If
How would I combat this?
Many thanks
Jimmi