End Sub Private Sub SetComboBox3() 'コンボボックスの分岐選択する With ComboBox3 .Clear .Font.Size = 12 If ComboBox2 = "サイクル" Then .AddItem "-1〜10" .AddItem "-1〜20" .AddItem "-1〜30" ElseIf ComboBox2 = "連続" Then .AddItem "-1〜10" .AddItem "-1〜20" .AddItem "-1〜30" End If End With End Sub Private Sub SetComboBox4() 'コンボボックスの分岐選択する With ComboBox4 .Clear .Font.Size = 12 'If ComboBox3 = "-1〜10" Then .AddItem "鉛" .AddItem "鉛フリー" 'ElseIf ComboBox3 = "-1〜20" Then ' .AddItem "鉛" ' .AddItem "鉛フリー" 'ElseIf ComboBox3 = "-1〜30" Then ' .AddItem "鉛" ' .AddItem "鉛フリー" 'End If End With End Sub Private Sub SetComboBox5() 'コンボボックスの分岐選択する With ComboBox5 .Clear .Font.Size = 12 If ComboBox4 = "鉛" Then .AddItem "ガラエポ" .AddItem "紙フェ" ElseIf ComboBox4 = "鉛フリー" Then .AddItem "ガラエポ" .AddItem "紙フェ" End If End With End Sub Private Sub SetComboBox6() 'コンボボックスの分岐選択する With ComboBox6 .Clear .Font.Size = 12 If ComboBox5 = "ガラエポ" Then .AddItem "100" .AddItem "500" .AddItem "1000" .AddItem "1500" .AddItem "2000" ElseIf ComboBox5 = "紙フェ" Then .AddItem "100" .AddItem "500" .AddItem "1000" .AddItem "1500" .AddItem "2000" End If End With End Sub
Private Sub SetComboBox7() 'コンボボックスの分岐選択する With ComboBox7 .Clear .Font.Size = 12 If ComboBox2 = "サイクル" & ComboBox3 = "-1〜10" & ComboBox6 = "100" Then
.AddItem "pbf22"
ElseIf ComboBox6 = "500" Then .AddItem "pb25" ElseIf ComboBox6 = "1000" Then .AddItem "pb26" ElseIf ComboBox6 = "1500" Then .AddItem "pb27" ElseIf ComboBox6 = "2000" Then .AddItem "pb28"
End If End With End Sub
Private Sub CommandButton2_Click() '終了ボタンで終了する Dim myend As Integer myend = MsgBox("終了しますか?", vbQuestion + vbYesNo) If myend = vbYes Then Unload Me End If End Sub
Private Sub CommandButton3_Click()
Dim strFind As Variant Dim msg As String Dim 行 As String '行の宣言 Dim 列 As String '列の宣言 Dim 最終行 As String Dim i As String Dim 検索行 As Range Sheets(3).Select Range("A2").Select
'変更前 Dim 行 As String Dim 行 As Integer '変更前 Dim 列 As String Dim 列 As Integer Dim 最終行 As String Dim 検索行 As String Dim メッセージ As Integer Dim 一致 As Range Dim myNO As Variant '変更前 Dim i As Long Dim i As Variant
Sheets(3).Select 最終行 = Range("A2").End(xlDown).Offset(1).Select 行 = ActiveCell.Row 列 = ActiveCell.Column myNO = TextBox1.Value 'A2から、データのあるところまでを選択するように変更しました 検索行 = Range(Cells(2, 1), Cells(行 - 1, 列)).Select '選択しているセルを検索するように変更しました Set 一致 = Selection.Find(what:=TextBox2.Text, lookat:=xlWhole) If 一致 Is Nothing Then MsgBox "データがありません。新規コード入力します。" Else i = Cells(行 - 1, 1).Value End If End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub userform_initialize()
With ComboBox1 'コンボボックス1に選択を入れる .Font.Size = 12
.AddItem "C" .AddItem "Y" .AddItem "X" End With
With ComboBox2 .Font.Size = 12 .AddItem "サイクル" .AddItem "連続"
End With
'SetComboBox3
With ComboBox8 .Font.Size = 12
.AddItem "A" .AddItem "B" .AddItem "C" .AddItem "D" .AddItem "E"