Hi Community, I am stuck in a VBA conundrum. I am trying to create multiple UserForm Textboxes in vba and Fill each one with a unique value either by index, or by some other means. I am able to get them to fill but when I do it seems that all the text boxes are being filled with the same values due to the there is no unique name distinction from textbox1 to textbox2, etc. I would imagine there has to be a way to do this, and I am stuck. Any help would be appreciated.
VBA Code:
Sub CharLoad()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim dict As New Scripting.Dictionary
Dim charArray(1 To 4) As String
Dim ColHeader As String
Dim txtBox As MSForms.TextBox
Dim h As Integer
h = 0
j = WorksheetFunction.CountA(Sheets(1).Range("A:A"))
For i = 1 To j
charArray(1) = Worksheets(1).Cells(i, 2)
charArray(2) = Worksheets(1).Cells(i, 3)
charArray(3) = Worksheets(1).Cells(i, 4)
charArray(4) = Worksheets(1).Cells(i, 5)
dict.Add Worksheets(1).Cells(i, 1), charArray
Next i
b = dict.Keys
For k = 1 To j
Set txtBox = UserForm1.mainFrm.Controls.Add("Forms.TextBox.1", "txtBox")
'tb = UserForm1.mainFrm.Controls.Add("Forms.TextBox.1", "txtBox")
txtBox.Top = h + 20
txtBox.Left = 6
h = h + 20
'txtBox.BackColor = RGB(255, 255, 0)
For i = 1 To j
[COLOR=rgb(247, 218, 100)]UserForm1.mainFrm.txtBox.Value = i & ". " & dict.Keys(i - 1)[/COLOR]
'UserForm1.ListBox2.AddItem dict.Item(b(i - 1))(1)
UserForm1.ListBox3.AddItem dict.Item(b(i - 1))(2)
UserForm1.ListBox4.AddItem dict.Item(b(i - 1))(3)
UserForm1.ListBox5.AddItem dict.Item(b(i - 1))(4)
'Debug.Print dict.Item(b(i - 1))(k)
Next i
Next k
End Sub