bence.andras
New Member
- Joined
- May 23, 2011
- Messages
- 2
Hello there,
i'm making an automated report file, and what i would like to do is hide specific collumns that have no value or come 0.(in order to not show on a graph)
However the given month determines which collumns i do not want.
So i wrote this:
Private Sub Worksheet_Change(ByVal Target As Range)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
If Target.Cells.Count = 1 And Target.Address = "$B$37" Then<o></o>
<o></o>
If LCase(Target.Value) = "jan'11" Then<o></o>
Columns("O:Y").EntireColumn.Hidden = True<o></o>
<o></o>
<o></o>
ElseIf LCase(Target.Value) = "feb'11" Then<o></o>
Columns("P:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "1 q '11 qtd (jan&feb)" Then<o></o>
Columns("P:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "1 q '11" Then<o></o>
Columns("Q:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "apr '11" Then<o></o>
Columns("R:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "may '11" Then<o></o>
Columns("S:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "2 q '11 qtd (apr&may)" Then<o></o>
Columns("S:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "2 q '11" Then<o></o>
Columns("T:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "jul '11" Then<o></o>
Columns("U:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "aug '11" Then<o></o>
Columns("V:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "3 q '11 qtd (jul&aug)" Then<o></o>
Columns("V:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "3 q '11" Then<o></o>
Columns("W:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "oct '11" Then<o></o>
Columns("X:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "nov '11" Then<o></o>
Columns("Y:Z").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "4 q '11 qtd (oct&nov)" Then<o></o>
Columns("Y:Z").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "4 q '11" Then<o></o>
Columns("O:Y").EntireColumn.Hidden = False<o></o>
ElseIf LCase(Target.Value) = "fy11" Then<o></o>
Columns("O:Y").EntireColumn.Hidden = False<o></o>
<o></o>
<o></o>
Else<o></o>
Columns("A:Z").EntireColumn.Hidden = False<o></o>
End If<o></o>
<o></o>
End If<o></o>
<o></o>
End Sub<o></o>
However my problem is that the cell which gives me the month is a vlookup function and not simply the text. So it doesn't work. If i type in the same thing there manually, then it does the job. (although another problem is when i pick a next month it doesnt change the hidden collumns, but **** that...)
Can somebody help me how to solve this issue. (please note that im at a very very beginner level with excel, so sorry for any obvious questions)
i'm making an automated report file, and what i would like to do is hide specific collumns that have no value or come 0.(in order to not show on a graph)
However the given month determines which collumns i do not want.
So i wrote this:
Private Sub Worksheet_Change(ByVal Target As Range)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
If Target.Cells.Count = 1 And Target.Address = "$B$37" Then<o></o>
<o></o>
If LCase(Target.Value) = "jan'11" Then<o></o>
Columns("O:Y").EntireColumn.Hidden = True<o></o>
<o></o>
<o></o>
ElseIf LCase(Target.Value) = "feb'11" Then<o></o>
Columns("P:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "1 q '11 qtd (jan&feb)" Then<o></o>
Columns("P:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "1 q '11" Then<o></o>
Columns("Q:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "apr '11" Then<o></o>
Columns("R:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "may '11" Then<o></o>
Columns("S:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "2 q '11 qtd (apr&may)" Then<o></o>
Columns("S:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "2 q '11" Then<o></o>
Columns("T:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "jul '11" Then<o></o>
Columns("U:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "aug '11" Then<o></o>
Columns("V:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "3 q '11 qtd (jul&aug)" Then<o></o>
Columns("V:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "3 q '11" Then<o></o>
Columns("W:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "oct '11" Then<o></o>
Columns("X:Y").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "nov '11" Then<o></o>
Columns("Y:Z").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "4 q '11 qtd (oct&nov)" Then<o></o>
Columns("Y:Z").EntireColumn.Hidden = True<o></o>
ElseIf LCase(Target.Value) = "4 q '11" Then<o></o>
Columns("O:Y").EntireColumn.Hidden = False<o></o>
ElseIf LCase(Target.Value) = "fy11" Then<o></o>
Columns("O:Y").EntireColumn.Hidden = False<o></o>
<o></o>
<o></o>
Else<o></o>
Columns("A:Z").EntireColumn.Hidden = False<o></o>
End If<o></o>
<o></o>
End If<o></o>
<o></o>
End Sub<o></o>
However my problem is that the cell which gives me the month is a vlookup function and not simply the text. So it doesn't work. If i type in the same thing there manually, then it does the job. (although another problem is when i pick a next month it doesnt change the hidden collumns, but **** that...)
Can somebody help me how to solve this issue. (please note that im at a very very beginner level with excel, so sorry for any obvious questions)