#excel #vba
#excel #vba
Вопрос:
Итак, я внезапно столкнулся с действительно странной проблемой, и мне действительно нужна помощь. В моем проекте Excel на vba есть 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) amp; "-" amp; Right(frm1.TextBox7.Value, 2)
MkDir (checklist)
filename = "Inventory Record " amp; Format(Now(), "DD-MMM-YYYY hh mm AMPM") amp; ".pdf"
fullfilename = "G:BusUnitsPHSample management" amp; checklist amp; "" amp; 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" amp; iRow) = TextBox1.Value
.Range("B" amp; iRow) = TextBox2.Value
.Range("C" amp; iRow) = TextBox3.Value
.Range("D" amp; iRow) = ComboBox2.Value
.Range("E" amp; iRow) = ComboBox3.Value
.Range("F" amp; iRow) = TextBox6.Value
.Range("G" amp; iRow) = TextBox7.Value
.Range("H" amp; iRow) = TextBox8.Value
.Range("I" amp; iRow) = TextBox9.Value
.Range("J" amp; iRow) = TextBox10.Value
.Range("K" amp; iRow) = TextBox11.Value
.Range("L" amp; iRow) = TextBox12.Value
.Range("M" amp; iRow) = TextBox13.Value
.Range("N" amp; iRow) = DTPicker1.Value
.Range("O" amp; iRow) = TextBox15.Value
.Range("P" amp; iRow) = TextBox16.Value
.Range("Q" amp; iRow) = TextBox17.Value
.Range("R" amp; iRow) = TextBox18.Value
.Range("S" amp; iRow) = TextBox20.Value
.Range("T" amp; iRow) = DTPicker3.Value
.Range("U" amp; iRow) = TextBox21.Value
.Range("V" amp; iRow) = TextBox22.Value
.Range("w" amp; iRow) = TextBox23.Value
.Range("X" amp; iRow) = DTPicker4.Value
.Range("Y" amp; iRow) = Application.UserName
.Range("Z" amp; iRow) = [Text(Now(), "DD-MM-YYYY HH:MM:SS")]
.Range("AA" amp; iRow) = TextBox24.Value
.Range("AB" amp; iRow) = cmbRD.Value
.Range("AC" amp; iRow) = newDate
.Range("AD" amp; 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" amp; iRow) = TextBox1.Value
.Range("B" amp; iRow) = TextBox13.Value
.Range("C" amp; iRow) = DTPicker2.Value
.Range("D" amp; iRow) = ComboBox7.Value
.Range("E" amp; iRow) = ComboBox8.Value
.Range("F" amp; iRow) = ComboBox6.Value
.Range("G" amp; iRow) = ComboBox1.Value
.Range("H" amp; iRow) = TextBox2.Value
.Range("I" amp; iRow) = ComboBox2.Value
.Range("J" amp; iRow) = TextBox3.Value
.Range("K" amp; iRow) = ComboBox3.Value
.Range("L" amp; iRow) = TextBox4.Value
.Range("M" amp; iRow) = ComboBox4.Value
.Range("N" amp; iRow) = TextBox5.Value
.Range("O" amp; iRow) = ComboBox5.Value
.Range("P" amp; iRow) = TextBox6.Value
.Range("Q" amp; iRow) = DTPicker3.Value
.Range("R" amp; iRow) = TextBox14.Value
.Range("S" amp; iRow) = DTPicker4.Value
.Range("T" amp; iRow) = TextBox9.Value
.Range("U" amp; iRow) = DTPicker1.Value
.Range("X" amp; iRow) = Application.UserName
.Range("Y" amp; iRow) = [Text(Now(), "DD-MM-YYYY HH:MM:SS")]
.Range("Z" amp; iRow) = TextBox15.Value
.Range("AA" amp; 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) amp; "-" amp; Right(frm3.TextBox1.Value, 2)
MkDir (checklist)
fAddress = "G:BusUnitsPHSample management"
finalpath = fAddress amp; checklist amp; "" amp; 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" amp; iRow), _
Address:=finalpath, _
ScreenTip:="file address", _
TextToDisplay:="Invoice " amp; frm3.TextBox1.Value
ws.Range("V" amp; iRow).Interior.ColorIndex = 37
Else
ws.Hyperlinks.Add Anchor:=id.Offset(, 21), _
Address:=finalpath, _
ScreenTip:="file address", _
TextToDisplay:="Invoice " amp; 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) amp; "-" amp; Right(frm3.TextBox1.Value, 2)
MkDir (checklist)
filename = "Transport Assesment" amp; Format(Now(), "DD-MMM-YYYY hh mm AMPM") amp; ".pdf"
fullfilename = "G:BusUnitsPHSample management" amp; checklist amp; "" amp; 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) amp; "-" amp; Right(frm3.TextBox1.Value, 2)
MkDir (checklist)
fAddress = "G:BusUnitsPHSample management"
finalpath = fAddress amp; checklist amp; "" amp; 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" amp; iRow), _
Address:=finalpath, _
ScreenTip:="file address", _
TextToDisplay:="Datalogger " amp; frm3.TextBox1.Value
ws.Range("W" amp; iRow).Interior.ColorIndex = 37
Else
ws.Hyperlinks.Add Anchor:=id.Offset(, 22), _
Address:=finalpath, _
ScreenTip:="file address", _
TextToDisplay:="Datalogger " amp; 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) amp; "-" amp; Right(frm3.TextBox1.Value, 2)
MkDir (checklist)
filename = "Transport Assesment" amp; Format(Now(), "DD-MMM-YYYY hh mm AMPM") amp; ".pdf"
fullfilename = "G:BusUnitsPHSample management" amp; checklist amp; "" amp; 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, в ней говорится, что она сбросит проект, и когда я нажимаю «Да», Excel просто вылетает.
Пожалуйста, помогите
Редактировать: после установки точки останова и запуска первого:
Комментарии:
1. Вы уверены, что это именно эта форма? Установите точку останова
Private Sub UserForm_Initialize()
во всех 3 формах, а затем запустите ее?2. Ошибка изменилась на ожидаемый конечный подраздел после установки точки останова, я добавил картинку
3. И обе ошибки, желтая стрелка, на самом деле находятся чуть выше подраздела userform_initialize. не на вспомогательном
4. Это выглядит как другая форма. Теперь проделайте то же самое с
Call Reset1
и нажмите клавишу F8, когда она будет выделена. вам нужно будет выполнить пошаговый код, чтобы найти ошибку5. Где бы ни было желтое изображение, начните нажимать F8 и перейдите к ошибочной строке