Student1000
05-19-2010, 10:31 AM
hello everyone. I'm facing a problem with a rather long if statement.
All I want to do is to display 1 picture if the value in Calculations!BH = 1, two pictures if the value = 2 etc.
The "ListBox1.ListIndex + 3" just makes sure that the right cell in my spreadsheet is selected.
however it just won't work.
Would be nice if someone could help me.
cheers
If Range("Calculations!BH" & ListBox1.ListIndex + 3).Value = 1 Then
NightPic1.Visible = True And _
NightPic2.Visible = False And _
NightPic3.Visible = False And _
NightPic4.Visible = False And _
NightPic5.Visible = False And _
NightPic6.Visible = False
ElseIf Range("Calculations!BH" & ListBox1.ListIndex + 3).Value = 2 Then
NightPic1.Visible = True And _
NightPic2.Visible = True And _
NightPic3.Visible = False And _
NightPic4.Visible = False And _
NightPic5.Visible = False And _
NightPic6.Visible = False
ElseIf Range("Calculations!BH" & ListBox1.ListIndex + 3).Value = 3 Then
NightPic1.Visible = True And _
NightPic2.Visible = True And _
NightPic3.Visible = True And _
NightPic4.Visible = False And _
NightPic5.Visible = False And _
NightPic6.Visible = False
ElseIf Range("Calculations!BH" & ListBox1.ListIndex + 3).Value = 4 Then
NightPic1.Visible = True And _
NightPic2.Visible = True And _
NightPic3.Visible = True And _
NightPic4.Visible = True And _
NightPic5.Visible = False And _
NightPic6.Visible = False
ElseIf Range("Calculations!BH" & ListBox1.ListIndex + 3).Value = 5 Then
NightPic1.Visible = True And _
NightPic2.Visible = True And _
NightPic3.Visible = True And _
NightPic4.Visible = True And _
NightPic5.Visible = True And _
NightPic6.Visible = False
End If
All I want to do is to display 1 picture if the value in Calculations!BH = 1, two pictures if the value = 2 etc.
The "ListBox1.ListIndex + 3" just makes sure that the right cell in my spreadsheet is selected.
however it just won't work.
Would be nice if someone could help me.
cheers
If Range("Calculations!BH" & ListBox1.ListIndex + 3).Value = 1 Then
NightPic1.Visible = True And _
NightPic2.Visible = False And _
NightPic3.Visible = False And _
NightPic4.Visible = False And _
NightPic5.Visible = False And _
NightPic6.Visible = False
ElseIf Range("Calculations!BH" & ListBox1.ListIndex + 3).Value = 2 Then
NightPic1.Visible = True And _
NightPic2.Visible = True And _
NightPic3.Visible = False And _
NightPic4.Visible = False And _
NightPic5.Visible = False And _
NightPic6.Visible = False
ElseIf Range("Calculations!BH" & ListBox1.ListIndex + 3).Value = 3 Then
NightPic1.Visible = True And _
NightPic2.Visible = True And _
NightPic3.Visible = True And _
NightPic4.Visible = False And _
NightPic5.Visible = False And _
NightPic6.Visible = False
ElseIf Range("Calculations!BH" & ListBox1.ListIndex + 3).Value = 4 Then
NightPic1.Visible = True And _
NightPic2.Visible = True And _
NightPic3.Visible = True And _
NightPic4.Visible = True And _
NightPic5.Visible = False And _
NightPic6.Visible = False
ElseIf Range("Calculations!BH" & ListBox1.ListIndex + 3).Value = 5 Then
NightPic1.Visible = True And _
NightPic2.Visible = True And _
NightPic3.Visible = True And _
NightPic4.Visible = True And _
NightPic5.Visible = True And _
NightPic6.Visible = False
End If