简体   繁体   English

将数据从Userform上的多个文本框传输到Excel工作表

[英]Transfer Data From Multiple Textboxes on Userform to Excel Worksheet

I am attempting to take the data from my input screen: 我试图从输入屏幕获取数据:

输入屏幕

And transfer it to an excel worksheet to store the data. 并将其传输到Excel工作表以存储数据。 This is where I would like the data to go: 这是我想要数据的地方:

产量

I am currently using this code: 我目前正在使用此代码:

ActiveCell=TextBox1.Value
ActiveCell.Offset(0,1)=TextBox2.Value

But I need to keep doing this for every textbox which seems very inefficient. 但我需要继续为每个看起来非常低效的文本框执行此操作。

Is there a more efficient way to transfer this data from the userform to the sheet? 有没有更有效的方法将这些数据从用户表单传输到工作表?

Any help would be greatly appreciated. 任何帮助将不胜感激。 Thanks! 谢谢!

try the following syntax to loop through the textboxes 尝试以下语法循环文本框

for i=0 to n ' n =number of textbox values to copy
   activecell.offset(0,i)=userform2.controls("textbox"& i+1).value
next i

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM