我有一个用于库存控制的用户表单,用于进出物品,我想做的就是修改下面的代码以在其代码旁边显示每个物品名称以进行搜索物品。
代码:
Private Sub ComboBox1_Click()
Dim i As Integer
Dim j As Integer
Dim final As Integer
Dim FINAL2 As Integer
For i = 2 To 1000
If Hoja5.Cells(i, 1) = "" Then
final = i - 1
Exit For
End If
Next
For i = 2 To 1000
If Hoja6.Cells(i, 1) = "" Then
FINAL2 = i - 1
Exit For
End If
Next
For i = 2 To final
If ComboBox1 = Hoja5.Cells(i, 1) Then
TextBox1 = Hoja5.Cells(i, 2)
Exit For
End If
Next
For j = 1 To FINAL2
If ComboBox1 = Hoja6.Cells(j, 1) Then
TextBox8 = Hoja6.Cells(j, 3)
Exit For
End If
Next
End Sub
Private Sub ComboBox1_Enter()
Dim i As Integer
Dim j As Integer
Dim H As Integer
Dim final As Integer
Dim tareas As String
ComboBox1.BackColor = &H80000005
For i = 1 To ComboBox1.ListCount
ComboBox1.RemoveItem 0
Next i
For j = 2 To 1000
If Hoja5.Cells(j, 1) = "" Then
final = j - 1
Exit For
End If
Next
For H = 2 To final
tareas = Hoja5.Cells(H, 1)
ComboBox1.AddItem (tareas)
Next
'End If
End Sub
表明所需修改的照片
我希望它是这样的:
样本文件
下载上述用户表单的示例 https://www.dropbox.com/s/xkmgi666z0p3y3j/stock%20sample.xls?dl=0
去做这个:
-
Set the ColumnCount
= 2 表示组合框
-
设置第二列值ComboBox1.Column(1,{rowIndex})
='价值'`。在你的代码中。它应该是这样的:
For i = 2 To final
tareas = Hoja5.Cells(i, 1)
ComboBox1.AddItem (tareas)
'-- set the first column
ComboBox1.Column(1, i - 2) = Hoja5.Cells(i, 2) 'the name
Next
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)