首页 > 解决方案 > 在用户窗体初始化中突然出现不同的错误

问题描述

所以,我突然陷入了一个非常奇怪的问题,我真的需要一些帮助。我的 vba excel 项目有 4 个主要表单,一切正常,突然有 2 个表单,userform_initialize 突然开始给我奇怪的错误

在此处输入图像描述

这是完整的表单代码:

Option Explicit
Private Sub ComboBox1_DropButtonClick()
Dim i As Long, lastrow As Long
Sheets("Inventory Record").Protect "Ramu@lt12", UserInterfaceOnly:=True
lastrow = Sheets("Inventory Record").Cells(Rows.count, 1).End(xlUp).Row
If Me.ComboBox1.ListCount = 0 Then
For i = 2 To lastrow
Me.ComboBox1.AddItem Sheets("Inventory Record").Cells(i, 3).Value
Next i
End If
End Sub

Private Sub imgPDF_Click()

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Worksheets("Inventory Record PDF").Activate
Dim checklist As String
Dim filename As String
Dim fullfilename As String

checklist = Left(frm1.TextBox7.Value, 4) & "-" & Right(frm1.TextBox7.Value, 2)
MkDir (checklist)
filename = "Inventory Record " & Format(Now(), "DD-MMM-YYYY hh mm AMPM") & ".pdf"
fullfilename = "G:\BusUnits\PH\Sample management\" & checklist & "\" & filename


ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    filename:=fullfilename, _
    IncludeDocProperties:=True, _
    Quality:=xlQualityStandard, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=True, _
    From:=1, _
    To:=1
    
Worksheets("Dashboard").Activate

End Sub


Private Sub imgEdit_Click()

    Dim msgValue As VbMsgBoxResult
    
    msgValue = MsgBox("Do you want to Edit the Entry?", vbYesNo + vbInformation, "Confirmation")
    
    If msgValue = vbNo Then Exit Sub

    frmEdit1.Show

End Sub

Private Sub imgReset_Click()

Dim msgValue As VbMsgBoxResult
    
msgValue = MsgBox("Do you want to Reset the Form?", vbYesNo + vbInformation, "Confirmation")
    
If msgValue = vbNo Then Exit Sub

Call Reset1

End Sub

Private Sub imgSave_Click()

Dim msgValue As VbMsgBoxResult
    
msgValue = MsgBox("Do you want to save the Data?", vbYesNo + vbInformation, "Confirmation")
    
If msgValue = vbNo Then Exit Sub
    

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Inventory Record")
Dim newDate As Date
newDate = DateAdd("yyyy", 1, DTPicker3.Value)
'find first row in database
iRow = ws.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
ws.Protect Password:="Ramu@lt12", UserInterfaceOnly:=True
With ws
.Range("A" & iRow) = TextBox1.Value
.Range("B" & iRow) = TextBox2.Value
.Range("C" & iRow) = TextBox3.Value
.Range("D" & iRow) = ComboBox2.Value
.Range("E" & iRow) = ComboBox3.Value
.Range("F" & iRow) = TextBox6.Value
.Range("G" & iRow) = TextBox7.Value
.Range("H" & iRow) = TextBox8.Value
.Range("I" & iRow) = TextBox9.Value
.Range("J" & iRow) = TextBox10.Value
.Range("K" & iRow) = TextBox11.Value
.Range("L" & iRow) = TextBox12.Value
.Range("M" & iRow) = TextBox13.Value
.Range("N" & iRow) = DTPicker1.Value
.Range("O" & iRow) = TextBox15.Value
.Range("P" & iRow) = TextBox16.Value
.Range("Q" & iRow) = TextBox17.Value
.Range("R" & iRow) = TextBox18.Value
.Range("S" & iRow) = TextBox20.Value
.Range("T" & iRow) = DTPicker3.Value
.Range("U" & iRow) = TextBox21.Value
.Range("V" & iRow) = TextBox22.Value
.Range("w" & iRow) = TextBox23.Value
.Range("X" & iRow) = DTPicker4.Value
.Range("Y" & iRow) = Application.UserName
.Range("Z" & iRow) = [Text(Now(), "DD-MM-YYYY HH:MM:SS")]
.Range("AA" & iRow) = TextBox24.Value
.Range("AB" & iRow) = cmbRD.Value
.Range("AC" & iRow) = newDate
.Range("AD" & iRow) = cmbDD.Value
End With
Set ws1 = Worksheets("Inventory Record PDF")
With ws1
.Range("C6").Value = TextBox1.Value
.Range("C7").Value = TextBox2.Value
.Range("C8").Value = TextBox3.Value
.Range("C9").Value = ComboBox2.Value
.Range("C10").Value = ComboBox3.Value
.Range("C11").Value = TextBox6.Value
.Range("C12").Value = TextBox13.Value
.Range("G6").Value = TextBox7.Value
.Range("G7").Value = TextBox8.Value
.Range("G8").Value = TextBox9.Value
.Range("G9").Value = TextBox10.Value
.Range("G10").Value = TextBox11.Value
.Range("G11").Value = TextBox12.Value
.Range("G13").Value = DTPicker1.Value
.Range("A15").Value = TextBox15.Value
.Range("B15").Value = TextBox16.Value
.Range("C15").Value = TextBox17.Value
.Range("D15").Value = TextBox18.Value
.Range("E15").Value = TextBox20.Value
.Range("F15").Value = DTPicker3.Value
End With
MsgBox "Saved Successfully"
'ws.Protect "Ramu@lt12", UserInterfaceOnly:=True
End Sub


Private Sub TextBox7_AfterUpdate()

    Application.ScreenUpdating = False
    Dim sh As Worksheet
    Application.DisplayAlerts = False
    Set sh = Worksheets("Inventory Record")
    If WorksheetFunction.CountIf(sh.Range("G:G"), frm1.TextBox7.Value) = 0 Then
        Exit Sub
    End If
    'x = frm3.TextBox1.Value
    'Application.WorksheetFunction.INDEX(ReturnValueRange,Application.WorksheetFunction.MATCH(LookUpValue, LookupRange, 0))
    On Error Resume Next
    With frm1
    
        .TextBox1 = Application.WorksheetFunction.Index(sh.Range("A:A"), WorksheetFunction.Match(frm1.TextBox7, sh.Range("G:G"), 0))
        .TextBox2 = Application.WorksheetFunction.Index(sh.Range("B:B"), WorksheetFunction.Match(frm1.TextBox7, sh.Range("G:G"), 0))
        .TextBox3 = Application.WorksheetFunction.Index(sh.Range("C:C"), WorksheetFunction.Match(frm1.TextBox7, sh.Range("G:G"), 0))
        .ComboBox2 = Application.WorksheetFunction.Index(sh.Range("D:D"), WorksheetFunction.Match(frm1.TextBox7, sh.Range("G:G"), 0))
        .ComboBox3 = Application.WorksheetFunction.Index(sh.Range("E:E"), WorksheetFunction.Match(frm1.TextBox7, sh.Range("G:G"), 0))
        .TextBox6 = Application.WorksheetFunction.Index(sh.Range("F:F"), WorksheetFunction.Match(frm1.TextBox7, sh.Range("G:G"), 0))
        .TextBox8 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 2, 0)
        .TextBox9 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 3, 0)
        .TextBox10 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 4, 0)
        .TextBox11 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 5, 0)
        .TextBox12 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 6, 0)
        .TextBox13 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 7, 0)
        .DTPicker1 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 8, 0)
        .TextBox15 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 9, 0)
        .TextBox16 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 10, 0)
        .TextBox17 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 11, 0)
        .TextBox18 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 12, 0)
        .TextBox20 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 13, 0)
        .DTPicker3 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 14, 0)
        .TextBox21 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 15, 0)
        .TextBox22 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 16, 0)
        .TextBox23 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 17, 0)
        .DTPicker4 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 18, 0)
        .TextBox24 = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 21, 0)
        .cmbRD = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 22, 0)
        .cmbDD = Application.WorksheetFunction.VLookup(frm1.TextBox7.Value, sh.Range("G:AD"), 24, 0)
    End With

End Sub


Private Sub UserForm_Initialize()
Call Reset1
With frm1
 .DTPicker1.Value = Date
 .DTPicker3.Value = Date
 .DTPicker4.Value = Date
End With
End Sub

另一种形式的另一个错误: 在此处输入图像描述

完整代码:

Public Sub CommandButton1_Click()
Dim iRow As Long
Dim ws, ws1 As Worksheet
Set ws = Worksheets("Transport Assesment")
ws.Protect Password:="Ramu@lt12", UserInterfaceOnly:=True

'find first row in database
iRow = ws.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Range("A" & iRow) = TextBox1.Value
.Range("B" & iRow) = TextBox13.Value
.Range("C" & iRow) = DTPicker2.Value
.Range("D" & iRow) = ComboBox7.Value
.Range("E" & iRow) = ComboBox8.Value
.Range("F" & iRow) = ComboBox6.Value
.Range("G" & iRow) = ComboBox1.Value
.Range("H" & iRow) = TextBox2.Value
.Range("I" & iRow) = ComboBox2.Value
.Range("J" & iRow) = TextBox3.Value
.Range("K" & iRow) = ComboBox3.Value
.Range("L" & iRow) = TextBox4.Value
.Range("M" & iRow) = ComboBox4.Value
.Range("N" & iRow) = TextBox5.Value
.Range("O" & iRow) = ComboBox5.Value
.Range("P" & iRow) = TextBox6.Value
.Range("Q" & iRow) = DTPicker3.Value
.Range("R" & iRow) = TextBox14.Value
.Range("S" & iRow) = DTPicker4.Value
.Range("T" & iRow) = TextBox9.Value
.Range("U" & iRow) = DTPicker1.Value
.Range("X" & iRow) = Application.UserName
.Range("Y" & iRow) = [Text(Now(), "DD-MM-YYYY HH:MM:SS")]
.Range("Z" & iRow) = TextBox15.Value
.Range("AA" & iRow) = TextBox16.Value
End With
Set ws1 = Worksheets("Transport Assesment PDF")
With ws1
.Range("D8").Value = TextBox1.Value
.Range("D12").Value = TextBox13.Value
.Range("I12").Value = DTPicker2.Value
.Range("D14").Value = ComboBox8.Value
.Range("I14").Value = ComboBox7.Value
.Range("D20").Value = ComboBox6.Value
.Range("D22").Value = ComboBox1.Value
.Range("F23").Value = TextBox2.Value
.Range("D24").Value = ComboBox2.Value
.Range("F26").Value = TextBox3.Value
.Range("D27").Value = ComboBox3.Value
.Range("F28").Value = TextBox4.Value
.Range("D29").Value = ComboBox5.Value
.Range("H30").Value = TextBox5.Value
.Range("G34").Value = TextBox6.Value
.Range("G36").Value = DTPicker3.Value
.Range("I36").Value = TextBox14.Value
.Range("G39").Value = DTPicker4.Value
.Range("E49").Value = TextBox9.Value
.Range("I49").Value = DTPicker1.Value
.Range("J8").Value = DTPicker1.Value
.Range("D20").Value = TextBox15.Value
End With

MsgBox "Saved Successfully"
End Sub

Public Sub CommandButton3_Click()
Application.ScreenUpdating = False
Dim x As Long
Dim ol As OLEObject
Dim ws As Worksheet
Set ws = Worksheets("Transport Assesment")
x = ws.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
Dim iRow As Long
iRow = WorksheetFunction.CountA(ws.Range("A:A")) + 1
Dim fpath As String
   'Get file path
    fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select Invoice to attach")
    If LCase(fpath) = "false" Then Exit Sub
    
Dim fname As String
Dim fAddress As String
Dim finalpath As String
fname = GetFilenameFromPath(fpath)
Dim checklist As String
checklist = Left(frm3.TextBox1.Value, 4) & "-" & Right(frm3.TextBox1.Value, 2)
MkDir (checklist)

fAddress = "G:\BusUnits\PH\Sample management\"
finalpath = fAddress & checklist & "\" & fname
FileCopy fpath, finalpath
     
ws.Unprotect Password:="Ramu@lt12"
 
Dim id As Range
Set id = ws.Range("A:A").Find(what:=frm3.TextBox1.Value, LookIn:=xlValues)
If id Is Nothing Then
            ws.Hyperlinks.Add Anchor:=ws.Range("V" & iRow), _
            Address:=finalpath, _
            ScreenTip:="file address", _
            TextToDisplay:="Invoice " & frm3.TextBox1.Value
            ws.Range("V" & iRow).Interior.ColorIndex = 37
            
Else
            ws.Hyperlinks.Add Anchor:=id.Offset(, 21), _
            Address:=finalpath, _
            ScreenTip:="file address", _
            TextToDisplay:="Invoice " & frm3.TextBox1.Value
            id.Offset(, 21).Interior.ColorIndex = 37
End If

Worksheets("Dashboard").Activate

End Sub
Private Sub CommandButton2_Click()
Call Reset3
End Sub


Private Sub CommandButton4_Click()
Application.ScreenUpdating = False
Worksheets("Transport Assesment PDF").Activate
Dim checklist As String
Dim filename As String
Dim fullfilename As String

checklist = Left(frm3.TextBox1.Value, 4) & "-" & Right(frm3.TextBox1.Value, 2)
MkDir (checklist)
filename = "Transport Assesment" & Format(Now(), "DD-MMM-YYYY hh mm AMPM") & ".pdf"
fullfilename = "G:\BusUnits\PH\Sample management\" & checklist & "\" & filename


ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    filename:=fullfilename, _
    IncludeDocProperties:=True, _
    Quality:=xlQualityStandard, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=True, _
    From:=1, _
    To:=1
End Sub

Private Sub CommandButton5_Click()
Application.ScreenUpdating = False
Dim x As Long
Dim ol As OLEObject
Dim ws As Worksheet
Set ws = Worksheets("Transport Assesment")
x = ws.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
Dim iRow As Long
iRow = WorksheetFunction.CountA(ws.Range("A:A")) + 1
Dim fpath As String
   'Get file path
    fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select Invoice to attach")
    If LCase(fpath) = "false" Then Exit Sub
    
Dim fname As String
Dim fAddress As String
Dim finalpath As String
fname = GetFilenameFromPath(fpath)
Dim checklist As String
checklist = Left(frm3.TextBox1.Value, 4) & "-" & Right(frm3.TextBox1.Value, 2)
MkDir (checklist)

fAddress = "G:\BusUnits\PH\Sample management\"
finalpath = fAddress & checklist & "\" & fname
FileCopy fpath, finalpath
     
ws.Unprotect Password:="Ramu@lt12"
 
 
Dim id As Range
Set id = ws.Range("A:A").Find(what:=frm3.TextBox1.Value, LookIn:=xlValues)
If id Is Nothing Then
            ws.Hyperlinks.Add Anchor:=ws.Range("W" & iRow), _
            Address:=finalpath, _
            ScreenTip:="file address", _
            TextToDisplay:="Datalogger " & frm3.TextBox1.Value
            ws.Range("W" & iRow).Interior.ColorIndex = 37
            
Else
            ws.Hyperlinks.Add Anchor:=id.Offset(, 22), _
            Address:=finalpath, _
            ScreenTip:="file address", _
            TextToDisplay:="Datalogger " & frm3.TextBox1.Value
            id.Offset(, 22).Interior.ColorIndex = 37
End If

Worksheets("Dashboard").Activate


End Sub

Private Sub Image1_Click()

Application.ScreenUpdating = False
Worksheets("Transport Assesment PDF").Activate
Dim checklist As String
Dim filename As String
Dim fullfilename As String

checklist = Left(frm3.TextBox1.Value, 4) & "-" & Right(frm3.TextBox1.Value, 2)
MkDir (checklist)
filename = "Transport Assesment" & Format(Now(), "DD-MMM-YYYY hh mm AMPM") & ".pdf"
fullfilename = "G:\BusUnits\PH\Sample management\" & checklist & "\" & filename


ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    filename:=fullfilename, _
    IncludeDocProperties:=True, _
    Quality:=xlQualityStandard, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=True, _
    From:=1, _
    To:=1

End Sub

Private Sub imgEdit_Click()

    Dim msgValue As VbMsgBoxResult
    
    msgValue = MsgBox("Do you want to Edit the Entry?", vbYesNo + vbInformation, "Confirmation")
    
    If msgValue = vbNo Then Exit Sub

    frm6.Show

End Sub

Private Sub imgReset_Click()

    Dim msgValue As VbMsgBoxResult
    
    msgValue = MsgBox("Do you want to reset the Form?", vbYesNo + vbInformation, "Confirmation")
    
    If msgValue = vbNo Then Exit Sub

    Call Reset3

End Sub

Private Sub imgSave_Click()
Dim msgValue As VbMsgBoxResult
    
    msgValue = MsgBox("Do you want to save the Data?", vbYesNo + vbInformation, "Confirmation")
    
    If msgValue = vbNo Then Exit Sub
    
    Call Save3
    
End Sub

Private Sub TextBox1_AfterUpdate()

    Application.ScreenUpdating = False
    Application.AutomationSecurity = msoAutomationSecurityLow
    Dim sh As Worksheet
    Application.DisplayAlerts = False
    Set sh = Worksheets("Transport Assesment")
    If WorksheetFunction.CountIf(sh.Range("A:A"), frm3.TextBox1.Value) = 0 Then
    
        Exit Sub
    End If
    'x = frm3.TextBox1.Value
    On Error Resume Next
    With frm3
    
        .TextBox13 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 2, 0)
        .DTPicker2 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 3, 0) 'Invoice date
        .ComboBox7 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 5, 0) 'Storage condition
        .ComboBox8 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 4, 0)
        .ComboBox6 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 6, 0)
        .TextBox15 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 26, 0)
        .ComboBox1 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 7, 0)
        .TextBox2 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 8, 0)
        .ComboBox2 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 9, 0)
        .TextBox3 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 10, 0)
        .ComboBox3 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 11, 0)
        .TextBox4 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 12, 0)
        .ComboBox4 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 13, 0)
        .TextBox5 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 14, 0)
        .ComboBox5 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 15, 0)
        .TextBox6 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 16, 0)
        .DTPicker3 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 17, 0)
        .TextBox14 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 18, 0)
        .DTPicker4 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 19, 0)
        .TextBox9 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 20, 0)
        .DTPicker1 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 21, 0)
        .TextBox16 = Application.WorksheetFunction.VLookup(frm3.TextBox1, sh.Range("A:AA"), 27, 0)
        
    End With

End Sub

Private Sub UserForm_Initialize()
With frm3
        .TextBox1.Value = ""
        .TextBox2.Value = ""
        .TextBox3.Value = ""
        .TextBox4.Value = ""
        .TextBox5.Value = ""
        .TextBox6.Value = ""
        .TextBox9.Value = ""
        .TextBox13.Value = ""
        .TextBox14.Value = ""
        .TextBox15.Value = ""
        .TextBox16.Value = ""
        
        .DTPicker1.Value = Date
        .DTPicker2.Value = Date
        .DTPicker3.Value = Date
        .DTPicker4.Value = Date
        
        .ComboBox1.Clear
        .ComboBox2.Clear
        .ComboBox3.Clear
        .ComboBox4.Clear
        .ComboBox5.Clear
        .ComboBox6.Clear
        .ComboBox7.Clear
        .ComboBox8.Clear
        
        End With

With ComboBox1
        .AddItem "Wooden Pack"
        .AddItem "Carton"
        .AddItem "Credo Box"
        .AddItem "Other"
 End With
 
 With ComboBox3
        .AddItem "Damaged"
        .AddItem "Intact"
        .AddItem "Opened"
        .AddItem "Other"
 End With
 
 With ComboBox2
        .AddItem "Damaged"
        .AddItem "Intact"
        .AddItem "Opened"
        .AddItem "Other"
 End With
 
 With ComboBox4
        .AddItem "Yes"
        .AddItem "No"
 End With
 
 With ComboBox5
        .AddItem "Yes"
        .AddItem "No"
 End With
 
 With ComboBox7
       .AddItem "Store below -15 C.(fridge)-(CODE -DEEP FREEZE)"
       .AddItem "Store in 2- 8 C.(Refrigerator)-( CODE-FRIGO)"
       .AddItem "Do not store above  25 C protect from moisture-(TEMPCONTROL)"
       .AddItem "Do not store above  25 C protect from light-(TEMPCONTROL )"
       .AddItem "Ambient moderate condition-(AMBIENT MODERATE)"
 End With
  With ComboBox6
       .AddItem "Switzerland (Basel)"
       .AddItem "China"
       .AddItem "Ringaskiddy (Ireland)"
       .AddItem "Germany"
       .AddItem "Italy"
       .AddItem "Japan"
       .AddItem "Slovenia"
       .AddItem " U.K (United Kingdom)"
       .AddItem "Deutschland"
       .AddItem "Others"
 End With
 With ComboBox8
       .AddItem "DEEP FREEZE"
       .AddItem "FRIGO"
       .AddItem "TEMPCONTROL"
       .AddItem "AMBIENT MODERATE"
       .AddItem "COLD"
 End With
 
 With cmbMaterial
 
    .AddItem "Reference Standard"
    .AddItem "Impurity"
    .AddItem "In-process samples"
    .AddItem "Packaging Materials"
 
 End With
 
With cmbQty

    .AddItem "All Samples"
    .AddItem "Others"

End With

 
End Sub

其他 2 个表单的 Initialize 和以前一样工作正常,我不知道这两个发生了什么。此外,每当我尝试删除整个 Initialize 语句时,它都会说它将重置项目,当我单击“是”时,excel 就会崩溃。

请帮忙

编辑:放置断点并运行第一个后: 在此处输入图像描述

标签: excelvba

解决方案


推荐阅读