所以昨晚一切都运转正常,现在正在发生这种情况。不确定问题出在哪里,所有其他的宏工作正常,我把它缩小到一个导致所有错误的用户形式。它正在处理的仓库管理文件中,添加新的输入功能(添加新的行表单)会冻结整个文件。
Sub addline()
' Adds line to top row, currently row 12
If UserForm2.TextBox3.Text = "" Then
UserForm2.TextBox3.Text = "Today"
End If
UserForm2.Show
'form2 does the rest of the code, this part works fine
End Sub
userform2的代码:
Dim strdate As String
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
If Not TextBox1.Text = "" Then
If Not TextBox2.Text = "" Then
If Not TextBox3.Text = "" Then
Sheets("Main").Rows(12).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B12").Value = False
Range("C12").Value = TextBox1.Text
Range("D12").Value = TextBox2.Text
'makeing the vlookup
Range("E12").FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-2],rhconv,5,False),""#ERROR"")"
'adding the date tag
Range("f12").NumberFormat = "@"
If TextBox3.Text = "Today" Then
strdate = Format(Now(), "mmm dd , yyyy")
Range("F12").Value = strdate
Else ' else just add the date provided
Range("F12").Value = TextBox3.Text
End If
UserForm2.Hide
Range("e12").Select
If Selection.Value = "#ERROR" Then
' this is for the vlookup, if theres no match let the user know
MsgBox "Line Match Not Found. Please add a match into the system or delete
the line and start again."
Else
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = "Today"
End If
'not sure why but theres a mistake somewhere posting C12 to A12 and G12 when this code works :P
Range("a12").Value = ""
Range("g12").Value = ""
Else
' if not everything filled dont let the user move on
MsgBox "Please fill in all fields before Sumbitting, or Cancel"
End If
Else
MsgBox "Please fill in all fields before Sumbitting, or Cancel"
End If
Else
MsgBox "Please fill in all fields before Sumbitting, or Cancel"
End If
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton2_Click()
' cancel button, works fine i thing the error is in the submit button above
UserForm2.Hide
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
我知道它的很多代码,但它让我疯狂,也是一个新手,所以生病需要一些帮助。感谢名单
答案 0 :(得分:0)
wooow!我发现了这个问题,我一直没有得到足够的ram"此代码中的问题只是为了找到问题是在插入行。
来自这个
Sheets("Main").Rows(12).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
到这个
Sheets("Main").Range("B12").Entirerow.Insert
想知道为什么调试器从未发现过这个问题? 不知道"整行"洙太多了