Fill a userform with saved data

Asked by At

A user fills a userform and I save the contents into a sheet.

I want, after opening the sheet, to populate the form with the saved data.

I write the data with;

For Each cCtl In begin.Controls
    If TypeOf cCtl Is MSForms.CheckBox Then
        Cells(y, 1) = cCtl.Name
        Cells(y, 2) = cCtl.Value
        y = y + 1
    End If

    If TypeOf cCtl Is MSForms.TextBox Then
        Cells(y, 1) = cCtl.Name
        Cells(y, 2) = cCtl.Value
        y = y + 1
    End If

This works and (some of) the results are:

  • cbklant Agentschap Telecom,
  • labelklant Omschrijving,
  • cbcalc Con van Doornik,
  • cbkans 50%

in cell A1 to B4 etc.

(cb = comboboxname)
(label = Labelcaption)

How do I populate the form from this Range by opening the file?

1 Answers

0
Con On

Thanks Mathieu, you put me in the right direction and I try to compare, when it is true then I can fill de value (I think);

Private Sub tmp10_Click()
y = 1
Dim cCtl As Control
For Each cCtl In begin.Controls
    For x = 1 To 67
    If cCtl.Name = Cells(x, 1) Then Cells(x, 4) = "true"
    Next
y = y + 1
Next
End Sub

And so, I think, I can handle the rest.