بهذا الكود يمكن ان يتسع الى 256 عمود
Private Sub UserForm_Initialize()
ÂÎÑ_ÎáíÉ = æÑÞÉ1.Range("IV1").End(xlToLeft).Column
Dim ãÑÈÚÇÊ_ÇáäÕæÕ As Control: Dim ãÑÈÚÇÊ_ÇáÚäÇæíä As Control
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For t = 1 To ÂÎÑ_ÎáíÉ
Set ãÑÈÚÇÊ_ÇáÚäÇæíä = Frame1.Controls.Add("forms.label.1", "label" & t, True)
With ãÑÈÚÇÊ_ÇáÚäÇæíä
.Left = Frame1.Width - 90: .Top = 1 + (t * 15)
.Width = 60: .Height = 15: .TextAlign = 3
Frame1.Controls("label" & t).Caption = Cells(1, t)
End With
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set ãÑÈÚÇÊ_ÇáäÕæÕ = Frame1.Controls.Add("forms.textbox.1", "textbox" & t, True)
With ãÑÈÚÇÊ_ÇáäÕæÕ
.Left = Frame1.Width - 160: .Top = 1 + (t * 15)
.Width = 90: .Height = 15: .TextAlign = 3
Frame1.Controls("textbox" & t).Text = Cells(2, t)
Frame1.ScrollHeight = Frame1.ScrollHeight + Frame1.Controls("textbox" & t).Height + 2
End With
Next t
End Sub
لو تلاحظ الكود لوجدت اننا غيرنا فقط Z1 بالقيمة IV1