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

前端 未结 3 1610
心在旅途
心在旅途 2021-02-10 09:08

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:35

    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 
    

提交回复
热议问题