如何将项目添加到列表框

时间:2019-11-13 10:35:21

标签: excel vba userform

我在多个文本框中的用户窗体上拥有一组数据。

我已经编写了一个代码来查找是否有空白的文本框,这会使数据表不完整。

如果数据不完整,我希望它使用我的批次号(位于Txtbox10A10中)并将该批次号放在我的列表框中,以便以后可以访问它以完成数据。

有什么办法可以做到这一点?我尝试了很多错误的多种方法。

1 个答案:

答案 0 :(得分:0)

抱歉,vba还是新手

我有以下代码集

enter code here

Dim i As Integer
Dim J As Integer
Dim uppercolJ As Integer
Dim Mistakes As Integer
Dim x As Integer
'    cmas = UserForm3.MultiPage1.Pages(UserForm3.MultiPage1.Value).Controls("Txtbox" & 1 & "A" & J)


Set Form = UserForm3.MultiPage1.Pages(UserForm3.MultiPage1.Value)
uppercolJ = 41
Mistakes = 0
        For J = 28 To uppercolJ
            ActiveTextBoxName = "Txtbox" & 1 & "A" & J

            If UserForm3.MultiPage1.Pages(3).Controls(ActiveTextBoxName) = "" Then
                Mistakes = Mistakes + 1

            Else


    End If
        Next J
         If Mistakes > 0 Then
  MsgBox "Cells are incomplete, saving for later completion"

Else
MsgBox "comp"
'Call save
End If
End Sub`````






now when Mistakes > 0 
then i would like it to save the batch no. of the product which can be found in Txtbox10A10
to a listbox i have created. so that if i come back tomorroww  to finish all my data i can call that information from the batch no. in my listbox,


i have all coding already done just not sure how to get it to add my backnumber to the listbox upon Mistakes > 0