繁体   English   中英

如何使用 VBA 根据活动工作表中的单元格自动填充 excel 表单?

[英]How to autofill the excel form based on the cell in the active worksheet using VBA?

在此处输入图像描述

我创建了一个 Excel 表单,并期望表单中的文本框能够由单元格 B2 中的值自动填充。 我已经尝试过,但似乎我在 VBA 中的代码对我不起作用。 我在下面附上了我的代码。

Private Sub UserForm_Click()

    With UserForm1
        .txtTextBox1.Value = Sheet7.Range("B10").Value
        
    End With


End Sub

使用如下形式的Initialize事件。

Private Sub UserForm_Initialize()
    Me.TextBox1 = Sheets("Sheet1").Range("B10") 'Change sheet1 to your sheet name.
End Sub

在此处输入图像描述

暂无
暂无

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

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