[英]how to get a value out of a cell into a userform vba excel
I want to use a value of my active worksheet to put in a userform. 我想使用活动工作表的值来放入用户表单。 This has to be dynamic because in my worksheet i have multiple values.
这必须是动态的,因为在我的工作表中我有多个值。 The userform open hisself if you click on a button using a macro.
如果您使用宏单击按钮,则用户窗体会自行打开。
Here are the pictures of the values that i want to put automatically in my userfrom and also my userform. 这是我要自动从我的用户以及我的用户表中输入的值的图片。
Thanx 谢谢
[enter image description here][2] enter image description here [在此处输入图像描述] [2] 在此处输入图像描述
In your worksheet (asuming your userform is named UserForm1). 在您的工作表中(假设您的用户窗体名为UserForm1)。 Change [your column] to the column number you want to autofire your macro.
将[您的列]更改为您要自动触发宏的列号。
Private Sub Worksheet_Change(ByVal Target As Range)
If UserForm1.Visible And Target.Column = [your column] Then
call UserForm1.GetCellText(Target.Row)
End If
End Sub
In your Userform (asuming your textboxes are named TextBox1, TextBox2...). 在您的用户窗体中(假设您的文本框名为TextBox1,TextBox2 ...)。
Sub GetCellText(xRow As Integer)
Dim i As Byte
For i = 1 To 7
Me.Controls("TextBox" & i).Value = Cells(xRow, i)
Next
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.