1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| Sub ComboBox1_Change()
Dim Data As Worksheet
Dim Reg As Worksheet
Dim Cy As Range
Dim Vendor_Ctry As Range
Dim nbline As Integer
Set Data = ThisWorkbook.Sheets("Data")
Set Reg = ThisWorkbook.Sheets("NOI_Reg")
Set Cy = Data.Range("G5")
Set Vendor_Ctry = Reg.Range("C3")
With Reg
nbline = .Cells(.Rows.Count, 1).End(xlUp).Row - 2
End With
For i = 0 To nbline
If NOI_Selection.ComboBox1.Value = Vendor_Ctry.Offset(i, 0) Then
If NOI_Selection.ComboBox1.Value = Cy.Offset(0, 0) Then
NOI_Selection.ComboBox2.List = Data.Range("D5:D6").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(1, 0) Then
NOI_Selection.ComboBox2.Value = Data.Range("D7").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(2, 0) Then
NOI_Selection.ComboBox2.Value = Data.Range("D8").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(3, 0) Then
NOI_Selection.ComboBox2.List = Data.Range("D9:D11").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(4, 0) Then
NOI_Selection.ComboBox2.List = Data.Range("D12:D13").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(5, 0) Then
NOI_Selection.ComboBox2.List = Data.Range("D14:D27").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(6, 0) Then
NOI_Selection.ComboBox2.Value = Data.Range("D28").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(7, 0) Then
NOI_Selection.ComboBox2.List = Data.Range("D29:D37").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(8, 0) Then
NOI_Selection.ComboBox2.Value = Data.Range("D38").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(9, 0) Then
NOI_Selection.ComboBox2.List = Data.Range("D39:D42").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(10, 0) Then
NOI_Selection.ComboBox2.Value = Data.Range("D43").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(11, 0) Then
NOI_Selection.ComboBox2.Value = Data.Range("D44").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(12, 0) Then
NOI_Selection.ComboBox2.Value = Data.Range("D45").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(13, 0) Then
NOI_Selection.ComboBox2.List = Data.Range("D46:D121").Value
Exit Sub
ElseIf NOI_Selection.ComboBox1.Value = Cy.Offset(14, 0) Then
NOI_Selection.ComboBox2.List = Data.Range("D122:D135").Value
Exit Sub
End If
Else
A = MsgBox(" No NOI associated with this Country", vbOKOnly + vbExclamation, WARNING)
If A = vbOK Then
Me.Hide
End If
End If
Next i
Me.Hide
End Sub |
Partager