我尝试编写一个用户表单,如果按下cmdbuton,用户表单将计算数据在两个文本框中的哪一个,并查看位置(第一个textobx)或查找数据的名称(第二个textbox)。
我在分析文本框的名称时遇到了问题。我想找到名称,获得它的位置,并在另一个用户窗体中加载该行的所有数据。问题是我不知道如何从.address中去掉数字,当我找到这个词时,我会得到这个数字。
Private Sub CommandButton2_Click()
If Not TextBox1.value = "" And TextBox2.value = "" Then
Sheet1.Cells(1, 15) = TextBox1.value
Unload Me
OpisVentila.Show
ElseIf TextBox1.value = "" And Not TextBox2.value = "" Then
Dim y As Range
Dim x As String
Dim z As String
Dim s As String
x = TextBox2.Text
Set y = Sheet1.Range("A:A").Find(x)
z = y.Address(0, 0)
s = StrConv(z, vbUnicode)
s = Split(Left(s, Len(s) - 1, vbNullChar))
Sheet1.Cells(1, 15) = s
Unload Me
PromjenaVentila.Show
ElseIf Not TextBox1.value = "" And Not TextBox2.value = "" Then
Msgbox "Please enter one way to find the desired location"
TextBox1 = ""
TextBox2 = ""
Else
Msgbox "You didn't chose any way to find the desired location"
End If
End Sub
1条答案
按热度按时间vwkv1x7d1#
下面的代码将为您提供行号: