Save the text of automatically added textbox RRS feed

  • Question

  • Hi,

    Using excel 2007 vba, I added a textbox automatically to my user form 

    Dim arrtxt() as Variant Private Sub UserForm_Initialize() Dim newtxt As MSForms.TextBox Dim txtTop

    Dim i txtTop=12 For i=0 to 3 Set newtxt = Me.Controls.Add("Forms.TextBox.1", "txtAuto "& i+1, false) ReDim Preserve arrtxt(0 To i ) As Variant arrtxt(i ) = newtxt.Name next i txtTop= txtTop+18 With newtxt .Width = 36 .Left = 92 .Top = txtTop .TextAlign = 2 .Font.Name = "Tahoma" .Font.Size = 9 End With End sub

    This code works correctly. But after I fill my textboxes in buttonsave _click  I want to save the text of the textboxes so I use this code

    dim j

    For j = 0 To UBound(arrtxt) Sheet1.cells(2,j+1)=arrtxt(j).text Next j

    But the 424 error is shown that says "Object required". What should I do? 

    • Edited by SSamira21 Sunday, August 23, 2015 4:56 PM
    Sunday, August 23, 2015 4:54 PM