Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42215

What is wrond in this code?

$
0
0
Hello,

Using VBA in Excel 2007.

Trying to minimize the code listings by using the code further down, but it is not working. It only works for the first Range mentioned in each "ElseIf". If I make a separate "ElseIf" for each Range ("Cell") than it works fine. I really hope this isnt necessary so what I am trying is to say is If ComboBox14.Value = Range("AC9") OR Range("AC10") and so on.
The OR code does not seem to work for me no matter what I try. How can I solve this?

P.S. I know now why my code under doesnt work, its because a comma and Space is not recognized as OR, but I think its recognized as AND. So how to fix the line of the first "ElseIf"?


Thanx in advance:)


Private Sub ComboBox14_Click()
Dim myarray1 As Variant
Dim myarray2 As Variant
Dim myarray3 As Variant
Dim myarray4 As Variant
Dim myarray5 As Variant
myarray1 = Range("e100:e131").Value
myarray2 = Range("q100:q121").Value
myarray3 = Range("ac100:ac110").Value
myarray4 = Range("ao100:ao113").Value
myarray5 = Range("e90:e91").Value
If ComboBox14.Value = Range("AC8") Then
Me.ComboBox1.List() = myarray5
Me.ComboBox2.List() = myarray5
Me.ComboBox3.List() = myarray5
Me.ComboBox4.List() = myarray5
Me.ComboBox5.List() = myarray5
Me.ComboBox6.List() = myarray5
Me.ComboBox7.List() = myarray5
Me.ComboBox8.List() = myarray5
Me.ComboBox9.List() = myarray5
Me.ComboBox10.List() = myarray5
Me.ComboBox11.List() = myarray5
Me.ComboBox12.List() = myarray5
ComboBox1.Value = "Velg utstyr her"
ComboBox2.Value = "Velg utstyr her"
ComboBox3.Value = "Velg utstyr her"
ComboBox4.Value = "Velg utstyr her"
ComboBox5.Value = "Velg utstyr her"
ComboBox6.Value = "Velg utstyr her"
ComboBox7.Value = "Velg utstyr her"
ComboBox8.Value = "Velg utstyr her"
ComboBox9.Value = "Velg utstyr her"
ComboBox10.Value = "Velg utstyr her"
ComboBox11.Value = "Velg utstyr her"
ComboBox12.Value = "Velg utstyr her"
ElseIf ComboBox14.Value = Range("AC9, AC10, AC11, AC19, AC20, AC21, AC22") Then
Me.ComboBox1.List() = myarray1
Me.ComboBox2.List() = myarray1
Me.ComboBox3.List() = myarray1
Me.ComboBox4.List() = myarray1
Me.ComboBox5.List() = myarray1
Me.ComboBox6.List() = myarray1
Me.ComboBox7.List() = myarray1
Me.ComboBox8.List() = myarray1
Me.ComboBox9.List() = myarray1
Me.ComboBox10.List() = myarray1
Me.ComboBox11.List() = myarray1
Me.ComboBox12.List() = myarray1
ComboBox1.Value = "Velg utstyr her"
ComboBox2.Value = "Velg utstyr her"
ComboBox3.Value = "Velg utstyr her"
ComboBox4.Value = "Velg utstyr her"
ComboBox5.Value = "Velg utstyr her"
ComboBox6.Value = "Velg utstyr her"
ComboBox7.Value = "Velg utstyr her"
ComboBox8.Value = "Velg utstyr her"
ComboBox9.Value = "Velg utstyr her"
ComboBox10.Value = "Velg utstyr her"
ComboBox11.Value = "Velg utstyr her"
ComboBox12.Value = "Velg utstyr her"
ElseIf ComboBox14.Value = Range("AC12, AC13, AC23, AC24") Then

And so on and so on.......

Viewing all articles
Browse latest Browse all 42215

Trending Articles