Hopefully this should be the last request for a while.
I have been using the following code to populate sequential textboxes in a UserForm where the each array is compiled of columns. In the following the sequence of cell values would be:-
For Draw 1 TxtBox1 = B5, TxtBox2 = C5, TxtBox3 = D5, TxtBox4 = E5, TxtBox5 = B6, TxtBox6 = C6 etc Through to Cell E8
For Draw 2 TxtBox1 = Y5, TxtBox2 = Z5, TxtBox3 = AA5, TxtBox4 = AB5, TxtBox5 = Y6, TxtBox6 = Z6 etc
I am looking for similar code but where the informaton is held in rows so all the TextBoxes per "Draw" (Combox Value) will be populated from a single row
For Draw 1 TxtBox1 = B5, TxtBox2 = B6, TxtBox3 = B7 TxtBox4 = B8 TxtBox5 = B9 etc
For Draw 2 TxtBox1 = C5, TxtBox2 = C6, TxtBox3 = C7 etc
A similar solution would be most appreciated
I have been using the following code to populate sequential textboxes in a UserForm where the each array is compiled of columns. In the following the sequence of cell values would be:-
For Draw 1 TxtBox1 = B5, TxtBox2 = C5, TxtBox3 = D5, TxtBox4 = E5, TxtBox5 = B6, TxtBox6 = C6 etc Through to Cell E8
For Draw 2 TxtBox1 = Y5, TxtBox2 = Z5, TxtBox3 = AA5, TxtBox4 = AB5, TxtBox5 = Y6, TxtBox6 = Z6 etc
VBA Code:
Option Explicit
Dim ws As Worksheet
Dim lngCtrlLoop As Long
Dim lngRowLoop As Long
Dim tbCounter As Long
Dim vCols As Variant
Dim vCol As Variant
Dim DrawToColsDict As Object
Private Sub userForm_Initialize()
Set ws = Sheets("Sheet1")
End Sub
Private Sub cmdCallResult_Click()
Set DrawToColsDict = CreateObject("Scripting.Dictionary")
With DrawToColsDict
.Add "Draw 1", Array("B", "C", "D", "E")
.Add "Draw 2", Array("Y", "Z", "AA", "AB")
End With
With Me
vCols = DrawToColsDict(.cboDrawNumber.Value)
tbCounter = 1
For lngRowLoop = 5 To 8
For Each vCol In vCols
.Controls("txtBox" & tbCounter).Text = ws.Cells(lngRowLoop, vCol).Text
tbCounter = tbCounter + 1
Next
Next
End With
End Sub
I am looking for similar code but where the informaton is held in rows so all the TextBoxes per "Draw" (Combox Value) will be populated from a single row
For Draw 1 TxtBox1 = B5, TxtBox2 = B6, TxtBox3 = B7 TxtBox4 = B8 TxtBox5 = B9 etc
For Draw 2 TxtBox1 = C5, TxtBox2 = C6, TxtBox3 = C7 etc
A similar solution would be most appreciated