简体   繁体   English

Excel VBA用户窗体texbox输入错误

[英]Excel VBA userform texbox input error

I am trying to create a macro that will input whatever is written in the userform textbox onto the active cell. 我正在尝试创建一个宏,该宏将把在用户窗体文本框中编写的任何内容输入到活动单元格中。 However, whenever I try to run that portion of the code, i get an error 438. Here is a sample of the part there shows up on the debug. 但是,每当我尝试运行该部分代码时,都会收到错误438。这是调试中显示的部分示例。

With Selection.Font
.Bold = True
End With
ActiveCell.Value = UserForm2.Controls("TextBox" & i).Caption
ActiveCell.Offset(1, 0).Select

Error 438 means the Object doesn't support the property or method. 错误438表示对象不支持该属性或方法。 Textbox.Caption doesn't exist. Textbox.Caption不存在。 For a full list of methods / properties see MSDN TextBox Properties 有关方法/属性的完整列表,请参见MSDN TextBox属性。

As on how to fix your code: ActiveCell.Value = UserForm2.Controls("TextBox" & i).Value or ActiveCell.Value = UserForm2.Controls("TextBox" & i).Text 关于如何修复代码: ActiveCell.Value = UserForm2.Controls("TextBox" & i).ValueActiveCell.Value = UserForm2.Controls("TextBox" & i).Text

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

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