اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

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

قام بنشر

السلام عليكم 

برجاء المساعده في كتابة كود 

عند كتابة الاكود في textbox1 تظهر الوصف في textbox2 تلقائي 

وشكرا Capture.JPG.79565d3caeb194f75d7f512e26c0c311.JPGtest.xlsm

  • أفضل إجابة
قام بنشر (معدل)

جرب هذا

Private Sub TextBox1_change()
Dim n As Range, J As Long, f As Long
Set WS = Worksheets("Sheet1")
clé = Me.TextBox1
f = WS.Cells(WS.Rows.Count, 2).End(xlUp).Row
With WS
   Set n = .Range("A2:A" & f).Find(What:=clé, LookIn:=xlValues, LookAt:=xlWhole, _
      SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False)
    If Not n Is Nothing Then
      J = n.Row
      Me.TextBox2 = .Range("B" & J)
      Else
      Me.TextBox2 = ""
    End If
  End With 
End Sub

 

بطريقة مختلفة 

Public Property Get WS() As Worksheet: Set WS = Worksheets("Sheet1")
End Property

Private Sub UserForm_Initialize()
Set J = CreateObject("Scripting.Dictionary")
  a = WS.Range("A2:A" & WS.[A65000].End(xlUp).Row)
  For i = LBound(a) To UBound(a)
    If a(i, 1) <> "" Then J(a(i, 1)) = ""
  Next i
  n = J.keys
  Me.ComboBox1.List = n
End Sub
'==================
Private Sub ComboBox1_Change()
Me.TextBox2 = Evaluate("=vlookup(" & """" & Me.ComboBox1.Value & """" & _
  ",A2:B" & Split(WS.[a2].CurrentRegion.Address, "$")(4) & ",2)")
End Sub

 

 

 

test.xlsm

تم تعديل بواسطه محمد هشام.
  • Like 1

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