Merhabalar 2 Adet comboboxsım var birinin ismi depo diğerinin ise location benim istediğim 1. comboda depo combasında 1 nolu depoyu seçtiğimde aşağsındaki leyout combosunda 1 nolu depoya ait lokasyonlaarı çıkartması kendimce bişey yapmaya çalıştım yalnız en altta görüldüğü gibi yaparsam liste uzun olduğunda çok uzun bir kod yazmam lazım bunu nasıl kısaltabiliriz veya daha değişik nasıl yapabiliriz? uığraştım denedim yapamadım yardımınızı bekliyorum.
Private Sub UserForm_Initialize()
Dim say As Integer
Sheets("DATA").Select
txtsira.Locked = True
If range("C2") = "" Then
say = WorksheetFunction.CountA(range("B1:B5000"))
txtstokadi.RowSource = "DATA!C2:C" & say + 1
Else
say = WorksheetFunction.CountA(range("B1:B65000"))
txtstokadi.RowSource = "DATA!C2:C" & say
End If
txtsira.Value = say
txtstokadi.SetFocus
'depo bilgileri
txtdepo.AddItem "1 Nolu Depo"
txtdepo.AddItem "2 Nolu Depo"
txtdepo.ListRows = 10
txtdepo.ListStyle = 1
txtdepo.Style = fmStyleDropDownCombo
Private Sub txtdepo_Change()
If txtdepo.Value = "1 Nolu Depo" Then
txtlocation.Clear
txtlocation.AddItem "A11"
txtlocation.AddItem "A12"
txtlocation.AddItem "A13"
txtlocation.AddItem "A14"
txtlocation.AddItem "A15"
txtlocation.AddItem "A16"
txtlocation.AddItem "A21" liste uzayıp gidiyor
End If
If txtdepo.Value = "2 Nolu Depo" Then
txtlocation.Clear
txtlocation.AddItem "A"
txtlocation.AddItem "B"
txtlocation.AddItem "C" bu listede uzun
End If
txtlocation.ListRows = 10
txtlocation.ListStyle = 1
txtlocation.Style = fmStyleDropDownCombo (combobox şekli)
End Sub
Aşağdaki kodu ise dopo comboboxta 1 nolu depo seçimi yapılıcan leyout comboboxta istediği çıkartması için kullanıyorum
Private Sub txtlocation_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If txtlocation.Value = "A11" Or txtlocation.Value = "A12" Then
Else
MsgBox "50 Nolu Depo Locationunu Yanlış Yazdınız!", vbInformation, "DİKKAT"
txtlocation.SetFocus
End If
End Sub
Private Sub UserForm_Initialize()
Dim say As Integer
Sheets("DATA").Select
txtsira.Locked = True
If range("C2") = "" Then
say = WorksheetFunction.CountA(range("B1:B5000"))
txtstokadi.RowSource = "DATA!C2:C" & say + 1
Else
say = WorksheetFunction.CountA(range("B1:B65000"))
txtstokadi.RowSource = "DATA!C2:C" & say
End If
txtsira.Value = say
txtstokadi.SetFocus
'depo bilgileri
txtdepo.AddItem "1 Nolu Depo"
txtdepo.AddItem "2 Nolu Depo"
txtdepo.ListRows = 10
txtdepo.ListStyle = 1
txtdepo.Style = fmStyleDropDownCombo
Private Sub txtdepo_Change()
If txtdepo.Value = "1 Nolu Depo" Then
txtlocation.Clear
txtlocation.AddItem "A11"
txtlocation.AddItem "A12"
txtlocation.AddItem "A13"
txtlocation.AddItem "A14"
txtlocation.AddItem "A15"
txtlocation.AddItem "A16"
txtlocation.AddItem "A21" liste uzayıp gidiyor
End If
If txtdepo.Value = "2 Nolu Depo" Then
txtlocation.Clear
txtlocation.AddItem "A"
txtlocation.AddItem "B"
txtlocation.AddItem "C" bu listede uzun
End If
txtlocation.ListRows = 10
txtlocation.ListStyle = 1
txtlocation.Style = fmStyleDropDownCombo (combobox şekli)
End Sub
Aşağdaki kodu ise dopo comboboxta 1 nolu depo seçimi yapılıcan leyout comboboxta istediği çıkartması için kullanıyorum
Private Sub txtlocation_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If txtlocation.Value = "A11" Or txtlocation.Value = "A12" Then
Else
MsgBox "50 Nolu Depo Locationunu Yanlış Yazdınız!", vbInformation, "DİKKAT"
txtlocation.SetFocus
End If
End Sub
