• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

birbiri ile ilişkili combobox

Katılım
4 Ağustos 2008
Mesajlar
261
Excel Vers. ve Dili
türkçe 2010
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
 
Keşke, özet bir dosya ekleyebilseydiniz.
 
örnek kod verilebilirse örneğin combobox 1 'e depo1, depo2, depo3 tanımlı, cobobox 2'ye a1,a2,a3,a4,a5,a6,a7,a8,a9,a10 tanımlı ben combobox 1 'depo 1 yazarsam. combobox 2 de a1,a2,a3 çıksın yazılabilsin, eğer farklı bişey yazılırsa hata mesajı çıksın. örneğin combobox 1'e depo2 yazarsam a4,a5,a6 çıksın yazılabilsin aynı şekilde başka bişey yazılamazsın fikir alışverişi güzel olur
 
örnek kod verilebilirse örneğin combobox 1 'e depo1, depo2, depo3 tanımlı, cobobox 2'ye a1,a2,a3,a4,a5,a6,a7,a8,a9,a10 tanımlı ben combobox 1 'depo 1 yazarsam. combobox 2 de a1,a2,a3 çıksın yazılabilsin, eğer farklı bişey yazılırsa hata mesajı çıksın. örneğin combobox 1'e depo2 yazarsam a4,a5,a6 çıksın yazılabilsin aynı şekilde başka bişey yazılamazsın fikir alışverişi güzel olur

Merhabalar,

"Depo" ve "Lokasyon" tanımları kodun içinde mi yeralacak? Yoksa herhangi bir kaynaktan (veya aralıktan) mı alınacak?

Gerçi verdiğiniz kod bloğunda, VBA kodlarının içine sabit olarak gömüleceği de anlaşılmakta ...

.
 
Sayın Ferhat Hocam Baya bi uğraştıktan sonra bulabildim aşağıdaki gibi yaparak kodu kısalttım
rivate Sub txtlocation_Exit(ByVal Cancel As MSForms.ReturnBoolean)




If txtdepo.Value = "50 Nolu Depo" Then
Dim harf() As Variant
harf = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
Dim rakam23() As Variant
rakam23 = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14")
Dim rakam4() As Variant
rakam4 = Array("1", "2", "3", "4", "5", "6")

Dim a, b, c, d As Integer

For a = 0 To 9
For b = 0 To 13
For c = 0 To 5

txtlocation.AddItem (harf(a) + rakam23(b) + rakam4(c))


Next c
Next b
Next a


End If
If txtlocation.MatchFound = True Then
Exit Sub
Else
MsgBox txtlocation.Value & " LOKASYONU LEYAOUT'ta YOK! Lütfen Doğru Location İsmi Girin! ", vbInformation, "LOKASYON İSİM HATASI"
Cancel = True
End If


End Sub

İlginiz için teşekkürler
 
Geri
Üst