اذهب الي المحتوي
أوفيسنا

مساعدة في وضع شرط ل ComboBox


إذهب إلى أفضل إجابة Solved by شوقي ربيع,

الردود الموصى بها

السلام عليكم ورحمة الله تعالى وبركاته

 

هل هذا الكود سليم أم لا

 

إستعملت كل المحاولات ولم تفلح معي

Private Sub ComboBox1_Change()
'====================================
If Me.ComboBox1.Value <> "" Then
Me.TextFind1.Visible = True
Me.TextFind2.Visible = False
End If
'====================================
If Me.ComboBox1.Value <> "" Then
Me.TextFind2.Visible = True
Me.TextFind1.Visible = False
End If
'====================================
End Sub

Private Sub ComboBox2_Change()
'====================================
If Me.ComboBox2.Value = "المجموعة 1" Then
Me.TextFind2.Visible = False
Me.TextFind1.Visible = True
End If
'====================================
If Me.ComboBox2.Value = "المجموعة 2" Then
Me.TextFind1.Visible = False
Me.TextFind2.Visible = True
End If
'====================================
End Sub


Private Sub UserForm_Initialize()
'====================================
With ThisWorkbook.ActiveSheet
    ComboBox1.AddItem .Range("A1")
    ComboBox1.AddItem .Range("C1")
    End With
'====================================
With ComboBox2
.AddItem " المجموعة 1 "
.AddItem " المجموعة 2 "
End With
'====================================
Me.TextFind1.Visible = False
Me.TextFind2.Visible = False
'====================================
End Sub

مساعدة في هذا المرفق

 

if ComboBox.rar

رابط هذا التعليق
شارك

أخي الحبيب جرب الكود بالشكل التالي :


Private Sub ComboBox1_Change()
    If Me.ComboBox1.Value <> "" Then
    Me.TextFind1.Visible = True
    Me.TextFind2.Visible = True
    End If
End Sub

Private Sub ComboBox2_Change()
    If Me.ComboBox2.Value = "المجموعة 1" Then
    Me.TextFind2.Visible = False
    Me.TextFind1.Visible = True
    End If
    '====================================
    If Me.ComboBox2.Value = "المجموعة 2" Then
    Me.TextFind1.Visible = False
    Me.TextFind2.Visible = True
    End If
End Sub

Private Sub UserForm_Initialize()
    With ThisWorkbook.ActiveSheet
        ComboBox1.AddItem .Range("A1")
        ComboBox1.AddItem .Range("C1")
    End With
    '====================================
    With ComboBox2
        .AddItem "المجموعة 1"
        .AddItem "المجموعة 2"
    End With
    '====================================
    Me.TextFind1.Visible = False
    Me.TextFind2.Visible = False
End Sub


رابط هذا التعليق
شارك

 

أخي الحبيب جرب الكود بالشكل التالي :


Private Sub ComboBox1_Change()
    If Me.ComboBox1.Value <> "" Then
    Me.TextFind1.Visible = True
    Me.TextFind2.Visible = True
    End If
End Sub

Private Sub ComboBox2_Change()
    If Me.ComboBox2.Value = "المجموعة 1" Then
    Me.TextFind2.Visible = False
    Me.TextFind1.Visible = True
    End If
    '====================================
    If Me.ComboBox2.Value = "المجموعة 2" Then
    Me.TextFind1.Visible = False
    Me.TextFind2.Visible = True
    End If
End Sub

Private Sub UserForm_Initialize()
    With ThisWorkbook.ActiveSheet
        ComboBox1.AddItem .Range("A1")
        ComboBox1.AddItem .Range("C1")
    End With
    '====================================
    With ComboBox2
        .AddItem "المجموعة 1"
        .AddItem "المجموعة 2"
    End With
    '====================================
    Me.TextFind1.Visible = False
    Me.TextFind2.Visible = False
End Sub


 

أستاذي الفاضل/ ياسر خليل

بعد التجربة تمت بنجاح العملية على (ComboBox2) فقط

عند الإختيار(ComboBox1)يظهر مع بعض وانا اريد كل واحد على حدا مثل ما عملت في(ComboBox2)

انا أريد ربط أي  قيمة تظهر في (ComboBox1) بتكست بوكس

مثلا :

القيم في (ComboBox1): المجموعة 1. المجموعة 2 وهي قيم متغيره لأنها مرتبطة بالخلايا ("A1").("C1")

عند إختيار من (ComboBox1) المجموعة 1  يظهر (TextFind1)

عند إختيار من (ComboBox1) المجموعة 2  يظهر (TextFind2) ويختفي (TextFind1)

رابط هذا التعليق
شارك

  • أفضل إجابة

السلام عليكم

جرب هذا

Private Sub ComboBox1_Change()
Dim i As Byte: i = Me.ComboBox1.ListIndex + 1
    Me.TextFind2.Visible = False
    Me.TextFind1.Visible = False
    Me.Controls("TextFind" & i).Visible = True
End Sub

Private Sub ComboBox2_Change()
Dim i As Byte: i = Me.ComboBox2.ListIndex + 1
    Me.TextFind2.Visible = False
    Me.TextFind1.Visible = False
    Me.Controls("TextFind" & i).Visible = True
End Sub

  • Like 2
رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information