أفضل إجابة lionheart قام بنشر سبتمبر 25, 2021 أفضل إجابة قام بنشر سبتمبر 25, 2021 First correct the combobox name from [Calss] to [Class] In userform module Dim ws As Worksheet, m As Long Private Sub StudentName_Enter() Dim a, i As Long, k As Long If Natija.Value <> "" And Class <> "" Then a = ws.Range("A2:D" & m).Value ReDim b(1 To UBound(a, 1)) For i = LBound(a) To UBound(a) If Val(a(i, 3)) = Val(Class.Value) And a(i, 4) = Natija.Value Then k = k + 1 b(k) = a(i, 2) End If Next i If k > 0 Then ReDim Preserve b(1 To k): StudentName.List = b End If End Sub Private Sub UserForm_Initialize() Dim a Set ws = Worksheets("Sheet1") m = ws.Cells(Rows.Count, "B").End(xlUp).Row a = GetDistinct(ws.Range("D2:D" & m)) Natija.List = a a = GetDistinct(ws.Range("C2:C" & m)) Class.List = a End Sub Function GetDistinct(ByVal oTarget As Range) As Variant Dim vArr, v, dic As Object Set dic = CreateObject("Scripting.Dictionary") vArr = oTarget For Each v In vArr If Not IsEmpty(v) Then dic(v) = v Next v GetDistinct = dic.Items() End Function 4
أحمد باجحنون قام بنشر سبتمبر 26, 2021 الكاتب قام بنشر سبتمبر 26, 2021 السلام عليكم ورحمة الله وبركاته أشكر أستاذي الفاضل على الجهد المبذول وجزاك الله خير 1
الردود الموصى بها
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.