Excel VBA Run-time error '424': Object Required when trying to copy TextBox

前端 未结 3 749
谎友^
谎友^ 2021-02-10 08:40

I\'m attempting to copy the contents of a text box from one workbook to another. I have no problem copying cell values from the first workbook to the

3条回答
  •  借酒劲吻你
    2021-02-10 09:36

    The issue is with this line

     xlo.Worksheets(1).Cells(2, 2) = TextBox1.Text
    

    You have the textbox defined at some other location which you are not using here. Excel is unable to find the textbox object in the current sheet while this textbox was defined in xlw.

    Hence replace this with

     xlo.Worksheets(1).Cells(2, 2) = worksheets("xlw").TextBox1.Text 
    

提交回复
热议问题