Option Explicit
[COLOR="Navy"]Dim[/COLOR] Myarray [COLOR="Navy"]As[/COLOR] Variant
Private [COLOR="Navy"]Sub[/COLOR] UserForm_Initialize()
Myarray = Sheet3.ListObjects("Table2").DataBodyRange.Value
[COLOR="Navy"]With[/COLOR] ListBox1
.ColumnCount = 6
.List = Myarray
.ColumnWidths = "70;70;70;70;70;70"
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]With[/COLOR] ComboBox1
.AddItem ""
.AddItem "Asia"
.AddItem "Europe"
.AddItem "America"
[COLOR="Navy"]End[/COLOR] With
'[COLOR="Green"][B]With ComboBox2[/B][/COLOR]
'[COLOR="Green"][B] .AddItem ""[/B][/COLOR]
'[COLOR="Green"][B] .AddItem ""[/B][/COLOR]
'[COLOR="Green"][B]End With[/B][/COLOR]
[COLOR="Navy"]With[/COLOR] Me.ComboBox3
.AddItem ""
.AddItem ">0"
.AddItem ">50"
.AddItem ">500"
.AddItem ">5000"
.AddItem ">50000"
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]With[/COLOR] Me.ComboBox4
.AddItem ""
.AddItem ">0"
.AddItem ">50"
.AddItem ">500"
.AddItem ">5000"
.AddItem ">50000"
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]With[/COLOR] Me.ComboBox5
.AddItem ""
.AddItem ">0"
.AddItem ">50"
.AddItem ">500"
.AddItem ">5000"
.AddItem ">50000"
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]With[/COLOR] Me.ComboBox6
.AddItem ""
.AddItem ">0"
.AddItem ">50"
.AddItem ">500"
.AddItem ">5000"
.AddItem ">50000"
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Private [COLOR="Navy"]Sub[/COLOR] ComboBox1_Change()
Me.ComboBox2 = ""
[COLOR="Navy"]Select[/COLOR] [COLOR="Navy"]Case[/COLOR] Me.ComboBox1
[COLOR="Navy"]Case[/COLOR] "Asia"
[COLOR="Navy"]With[/COLOR] Me.ComboBox2
.AddItem ""
.AddItem "Country1"
.AddItem "Country2"
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Case[/COLOR] "Europe"
[COLOR="Navy"]With[/COLOR] Me.ComboBox2
.AddItem ""
.AddItem "Country3"
.AddItem "Country4"
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Case[/COLOR] "America"
[COLOR="Navy"]With[/COLOR] Me.ComboBox2
.AddItem ""
.AddItem "Texas"
.AddItem "Ohio"
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]End[/COLOR] Select
Update
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Private [COLOR="Navy"]Sub[/COLOR] ComboBox2_Change()
Update
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Private [COLOR="Navy"]Sub[/COLOR] ComboBox3_Change()
Update
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Private [COLOR="Navy"]Sub[/COLOR] ComboBox4_Change()
Update
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Private [COLOR="Navy"]Sub[/COLOR] ComboBox5_Change()
Update
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Private [COLOR="Navy"]Sub[/COLOR] ComboBox6_Change()
Update
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
[COLOR="Navy"]Sub[/COLOR] Update()
[COLOR="Navy"]Dim[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Sn [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String,[/COLOR] Fd [COLOR="Navy"]As[/COLOR] Boolean, nn [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
ReDim Ray(1 To UBound(Myarray, 1), 1 To UBound(Myarray, 2))
[COLOR="Navy"]For[/COLOR] n = 1 To UBound(Myarray)
Fd = False
[COLOR="Navy"]For[/COLOR] ac = 1 To 6
[COLOR="Navy"]If[/COLOR] ac < 3 [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]If[/COLOR] Me.Controls("Combobox" & ac).Object.Value = "" Or Myarray(n, ac) _
= Me.Controls("Combobox" & ac).Object.Value [COLOR="Navy"]Then[/COLOR]
Fd = True
[COLOR="Navy"]Else[/COLOR]
Fd = False
[COLOR="Navy"]Exit[/COLOR] For
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]ElseIf[/COLOR] ac > 2 [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]If[/COLOR] Me.Controls("Combobox" & ac).Object.Value = "" Or Myarray(n, ac) _
> Val(Mid(Me.Controls("Combobox" & ac).Object.Value, 2)) [COLOR="Navy"]Then[/COLOR]
Fd = True
[COLOR="Navy"]Else[/COLOR]
Fd = False
[COLOR="Navy"]Exit[/COLOR] For
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] ac
[COLOR="Navy"]If[/COLOR] Fd [COLOR="Navy"]Then[/COLOR]
c = c + 1
[COLOR="Navy"]For[/COLOR] nn = 1 To 6
Ray(c, nn) = Myarray(n, nn)
[COLOR="Navy"]Next[/COLOR] nn
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]With[/COLOR] ListBox1
.Clear
.List = Ray
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]