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

المطلوب تعديل الكود


إذهب إلى أفضل إجابة Solved by أ / محمد صالح,

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

  • أفضل إجابة

يمكنك استعمال هذا الكود في حدث تهيئة النموذج والاستغناء عن إجراء add_comp

Private Sub UserForm_Initialize()
With Sheets("الصفحة الرئيسية")
Lr = .Cells(Rows.Count, 23).End(xlUp).Row
lr2 = .Cells(Rows.Count, 34).End(xlUp).Row
For n = 2 To lr2
Me.ComboBox1.AddItem .Range("ah" & n)
Next n
For n = 2 To Lr
Me.ComboBox1.AddItem .Range("w" & n)
Next n
End With
End Sub

مع تعديل خاصية عدد الأعمدة ColumnCount إلى 1 في خصائص ComboBox1

بالتوفيق 

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

Rem In UserForm Module
Rem ------------------
Private Sub UserForm_Initialize()
    Dim a
    With ThisWorkbook.Worksheets(1)
        a = MergeRanges(.Range("AH2").Resize(Application.CountA(.Columns("AH"))), .Range("W2").Resize(Application.CountA(.Columns("W"))))
    End With
    Me.ComboBox1.List = a
End Sub

Rem In Standard Module
Rem ------------------
Function MergeRanges(ParamArray args())
    Dim e, cell As Range
    ReDim temp(0)
    For Each e In args
        For Each cell In e
            If cell <> "" Then
                temp(UBound(temp)) = cell
                ReDim Preserve temp(UBound(temp) + 1)
            End If
        Next cell
    Next e
    ReDim Preserve temp(UBound(temp) - 1)
    MergeRanges = Application.Transpose(temp)
End Function

 

  • Thanks 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