Hello All,
First post. New to VBA so really confused on what to do next.
What I am trying to achieve:
In Sheet 1, I have a drop down from "1 to 11"
If someone selects 1, I want to hide Columns D:M in Sheet 13. If someone selects 2, I want to hide columns E:M in Sheet 13, and so on.
This is the code I have so far:
If [B9] = "1" Then
Sheet13.Columns("D:M").EntireColumn.Hidden = True
Else
Sheet13.Columns("D:M").EntireColumn.Hidden = False
End If
If [B9] = "2" Then
Sheet13.Columns("E:M").EntireColumn.Hidden = True
Else
Sheet13.Columns("E:M").EntireColumn.Hidden = False
End If
This code works if I select "2", but when I select "1" it ONLY hides column D, and not the remaining E:M. I also want to extend this code if I select 3 (Hide F:M), 4 (Hide G:M), etc...
First post. New to VBA so really confused on what to do next.
What I am trying to achieve:
In Sheet 1, I have a drop down from "1 to 11"
If someone selects 1, I want to hide Columns D:M in Sheet 13. If someone selects 2, I want to hide columns E:M in Sheet 13, and so on.
This is the code I have so far:
If [B9] = "1" Then
Sheet13.Columns("D:M").EntireColumn.Hidden = True
Else
Sheet13.Columns("D:M").EntireColumn.Hidden = False
End If
If [B9] = "2" Then
Sheet13.Columns("E:M").EntireColumn.Hidden = True
Else
Sheet13.Columns("E:M").EntireColumn.Hidden = False
End If
This code works if I select "2", but when I select "1" it ONLY hides column D, and not the remaining E:M. I also want to extend this code if I select 3 (Hide F:M), 4 (Hide G:M), etc...