|
▼seg さん:
▼Yukiさん:
すみません
情報が足りなさすぎでした。
今、下記のようにコードを記述してます
エラーが出るまでのところまで記載します
Private Sub CommandButton1_Click()
Dim 号Start As Integer, 号End As Integer
Dim SFX As String, WO As String
Dim WO最終行 As Integer
'********************
Dim LastR As Integer
Dim ShBOM As Worksheet, ShMas1 As Worksheet, ShMas2 As Worksheet, ShMas3 As Worksheet, ShWO As Worksheet
Dim Lev As Variant, Lev2 As Variant, Tar As Variant
Dim Parts As String, TopParts As String
Dim TopRange As Range
Dim TopKey As Integer
Dim MyLen As Integer, Pos As Integer
Dim EC As Variant
Dim MyType As Variant
Dim F判定 As Variant
Dim F As Variant
Dim MAPLNo As Integer
Dim Mas1R As Integer, Mas2R As Integer, Mas3R As Integer
Dim WS1 As Worksheet, flag As Boolean
Dim WS2 As Worksheet, flag2 As Boolean
Dim WS3 As Worksheet, flag3 As Boolean
Set ShWO = Worksheets("WO")
'号機情報
If UserForm2.LineStxt = "" Then
MsgBox "号機を入力して下さい"
'End
Exit Sub
Else
If UserForm2.LineStxt.Value = UserForm2.LineEtxt.Value Or LineEtxt.Value = "" Then
号Start = UserForm2.LineStxt.Value
号End = UserForm2.LineStxt.Value
Else
号Start = UserForm2.LineStxt.Value
号End = UserForm2.LineEtxt.Value
End If
End If
'SFX
If UserForm2.OptionButton1.Value Then
SFX = "-101"
WO = "部品用"
ElseIf UserForm2.OptionButton2.Value Then
SFX = "-201"
WO = "部品用"
ElseIf UserForm2.OptionButton3.Value Then
SFX = "-301"
WO = "部品用"
ElseIf UserForm2.OptionButton4.Value Then
SFX = "-111"
WO = "部品用"
ElseIf UserForm2.OptionButton8.Value Then
SFX = "-101"
WO = "組立用"
ElseIf UserForm2.OptionButton6.Value Then
SFX = "-201"
WO = "組立用"
ElseIf UserForm2.OptionButton5.Value Then
SFX = "-301"
WO = "組立用"
ElseIf UserForm2.OptionButton7.Value Then
SFX = "-111"
WO = "組立用"
Else
MsgBox "WOを選択して下さい"
'End
Exit Sub
End If
Set ShBOM = Worksheets("BOM")
LastR = ShBOM.Range("B65536").End(xlUp).Row
For i = 11 To LastR
If ShBOM.Range("A" & i).Value = "★" Then
Lev = ShBOM.Range("B" & i).Value '階層
Parts = ShBOM.Range("D" & i).Value '部品番号
Worksheets("原紙").Copy after:=Worksheets(Sheets.Count) ’←ここでたまにエラーがでます
Worksheets(Sheets.Count).Name = Parts & "_" & Format(号Start, "0000")
Set ShMas1 = Worksheets(Parts & "_" & Format(号Start, "0000"))
うまくいくときもあればうまくいかなくなるときもあります
どう、回避をしたらいいのでしょうか?
よろしくお願いします
|
|