Return 基于组合框和标签中的两个条件的 Textbox1 值
Return on Textbox1 value based upon two criterias in combobox and label
希望你一切都好。尝试了很多都没有成功,请专家帮助。
我在 Sheet1 中有一个包含 3 列的价目表:
医疗程序
类型
过程值
在用户表单中,我需要 return 在 Textbox1 中根据在 combobox1 中选择的标准(具有可以在 Sheet1 的医疗程序列中找到的值)和 label1 中的标题的程序值(实际上已经填充了可以在工作表 1 的“类型”列中遇到的值)。
我尝试在用户 B Hart 的 Whosebug 中找到这个(谢谢 B Hart!),但我无法在文本框中将其更改为 return 作为数值(这个 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
也许是这样的:
Private Sub combobox1_Change()
Dim lastRow As Integer
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
With Me
For r = 2 To lastRow
If Sheets("Sheet1").Cells(r, 1) = .ComboBox1.Value And Sheets("Sheet1").Cells(r, 2) = .Label1.Caption Then
.TextBox1.Text = Sheets("Sheet1").Cells(r, 3)
Exit For
End If
Next
End With
End Sub
希望你一切都好。尝试了很多都没有成功,请专家帮助。
我在 Sheet1 中有一个包含 3 列的价目表:
医疗程序
类型
过程值
在用户表单中,我需要 return 在 Textbox1 中根据在 combobox1 中选择的标准(具有可以在 Sheet1 的医疗程序列中找到的值)和 label1 中的标题的程序值(实际上已经填充了可以在工作表 1 的“类型”列中遇到的值)。
我尝试在用户 B Hart 的 Whosebug 中找到这个(谢谢 B Hart!),但我无法在文本框中将其更改为 return 作为数值(这个 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
也许是这样的:
Private Sub combobox1_Change()
Dim lastRow As Integer
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
With Me
For r = 2 To lastRow
If Sheets("Sheet1").Cells(r, 1) = .ComboBox1.Value And Sheets("Sheet1").Cells(r, 2) = .Label1.Caption Then
.TextBox1.Text = Sheets("Sheet1").Cells(r, 3)
Exit For
End If
Next
End With
End Sub