R
Ryan H
I have a column with a values in it. I want to load my userform (frmPF) with
these values with the code below, but my textboxes, comboboxes are empty when
the userform shows, why?
Sub LoadUserform()
Dim ctrlArray As Variant
Dim i As Long
Dim wksItem As Worksheet
Dim n As Long
' set worksheet to recall userform data
Set wksItem = Sheets("Data Storage")
' find column number of reference number
n = WorksheetFunction.Match(Target, wksItem.Rows("1:1"), 0)
' array of control values
With frmPF
ctrlArray = Array(.TextBox1, .TextBox1, .TextBox1, .TextBox1,
..ComboBox1)
End With
For i = LBound(ctrlArray) To UBound(ctrlArray)
ctrlArray(i) = wksItem.Cells(i, n)
Next i
frmPF.Show
End Sub
these values with the code below, but my textboxes, comboboxes are empty when
the userform shows, why?
Sub LoadUserform()
Dim ctrlArray As Variant
Dim i As Long
Dim wksItem As Worksheet
Dim n As Long
' set worksheet to recall userform data
Set wksItem = Sheets("Data Storage")
' find column number of reference number
n = WorksheetFunction.Match(Target, wksItem.Rows("1:1"), 0)
' array of control values
With frmPF
ctrlArray = Array(.TextBox1, .TextBox1, .TextBox1, .TextBox1,
..ComboBox1)
End With
For i = LBound(ctrlArray) To UBound(ctrlArray)
ctrlArray(i) = wksItem.Cells(i, n)
Next i
frmPF.Show
End Sub