【发布时间】:2016-04-22 05:11:35
【问题描述】:
希望你一切都好。在尝试了很多但没有成功后需要专家的帮助,拜托。
我在 Sheet1 中有一个包含 3 列的价目表:
医疗程序
类型
过程的价值
在用户表单中,我需要在 Textbox1 中返回基于在组合框 1 中选择的标准的程序值(可以在 Sheet1 的医疗程序列中找到值)和 label1 中的标题(实际上已经填充了可以在 Sheet1) 的类型列中遇到的值。
我在用户 B Hart 的 stackoverflow 中尝试了这个(谢谢,B Hart!),但我无法将其更改为在文本框中作为数值返回(这个 vba 将找到的值插入到列表框代替)。另一个问题是下面的标准在两个组合框中。我需要两个标准在组合框中,另一个在标签中。
Private Sub GetCondStrandValue()
Dim iRow As Long
Dim strValue As String
strValue = vbNullString
If Me.ComboBox1.Value = vbNullString Or Me.ComboBox2.Value = vbNullString Then Exit Sub
With Planilha1
For iRow = 2 To .Range("A65536").End(xlUp).Row
If StrComp(.Cells(iRow, 1).Value, Me.ComboBox1.Value, 1) = 0 And _
StrComp(.Cells(iRow, 2).Value, Me.ComboBox2.Value, 1) = 0 Then
strValue = .Cells(iRow, 3).Value
Exit For
End If
Next
End With
If strValue = vbNullString Then Exit Sub
With Me.ListBox1
'If you only want a single value in the listbox un-comment the .clear line
'Otherwise, values will continue to be added
'.Clear
.AddItem strValue
.Value = strValue
.SetFocus
End With
End Sub
【问题讨论】:
-
@DirkReichel 谢谢!我用上面的尝试编辑了问题