0
昨夜はすべてがうまくいきました。問題がどこにあるのかわからない場合は、他のすべてのマクロが正常に動作し、すべてのエラーの原因となっている1つのuserformに絞り込んでいます。私が取り組んでいる倉庫管理ファイルです。新しいエントリ機能を追加すると(新しい行形式を追加すると)、ファイル全体がフリーズしています。 userform2ためこのVBAマクロは私のファイルを破壊していますが、理由は分かりません
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
コード:
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
私はコードのその多くを知っているが、その私にナットを駆動するには、また、初心者ので、病気の必要性を少しイム少しの助け。高等学校
問題を引き起こしている可能性のある行にブレークポイントを設定してください。 –
[デバッグコード](http://www.cpearson.com/excel/DebuggingVBA.aspx)を知っていますか? –
userformsの* default instance *を使用して、グローバル状態を認識せずに格納しています。ユーザーフォーム/ダイアログのより高度な、オブジェクト指向の処理について知りたい場合は、[この記事を読む](https://rubberduckvba.wordpress.com/2017/10/25/userform1-show/)(免責事項:私はそれ)。 –