| 
    
     |  | お世話になります。 
 ユーザーフォームを作成して入力・修正・削除等を行おうとしていたのですが、
 作動しません。
 コードにおかしな所がありますか?
 宜しくお願い致します。
 
 A B    C     D  E       F   G  H  I
 No. 氏名     生年月日  年齢     入院年月日   フリガナ    表示 4
 1  大浦     1950/10/17  57     2007/4/22   オオウラ    最終 23
 2  佐藤     1952/12/14  55     2007/12/16   サトウ
 3  加藤     1946/12/07  61     2008/2/29   カトウ
 
 
 Private Sub CommandButton1_Click()
 If Cells(1, 9).Value > 2 Then
 Cells(1, 9).Value = Cells(1, 9).Value - 1
 End If
 データー表示
 End Sub
 
 Private Sub CommandButton2_Click()
 If Cells(1, 9).Value > Cells(2, 9) Then
 Cells(1, 9).Value = Cells(1, 9).Value + 1
 End If
 データー表示
 End Sub
 
 Private Sub CommandButton3_Click()
 入力結果 = MsgBox("登録しますか", vbYesNo)
 If 入力結果 = 7 Then
 If ToggleButton1.Value = True Then
 表示 = Cells(2, 9).Value + 1
 Else
 表示 = Cells(2, 9).Value
 End If
 Cells(表示, 1).Value = TextBox1.Value
 Cells(表示, 2).Value = TextBox2.Value
 Cells(表示, 3).Value = TextBox3.Value
 Cells(表示, 4).Value = TextBox4.Value
 Cells(表示, 5).Value = TextBox5.Value
 Cells(表示, 6).Value = TextBox6.Value
 If ToggleButton1.Value = True Then
 データークリア
 TextBox1.Value = Cells(表示, 1).Value + 1
 Else
 データー表示
 End If
 End If
 End Sub
 
 Private Sub CommandButton4_Click()
 
 入力結果 = MsgBox("表示されているデータを削除しますか", vbYesNo)
 
 If 入力結果 = 6 Then
 
 表示行 = Cells(1, 9).Value
 Range(Cells(表示, 1), Cells(表示, 6)).Select
 Selection.Delete shift:=xlUp
 
 
 If Cells(2, 9).Value = 1 Then
 ToggleButton1.Value = True
 Else
 If 表示 > 2 Then
 Cells(1, 9).Value = 表示 - 1
 End If
 データ表示
 End If
 End If
 End Sub
 Private Sub ToggleButton1_Change()
 
 If ToggleButton1.Value = True Then
 
 データクリア
 CommandButton1.Enabled = False
 CommandButton2.Enabled = False
 CommandButton4.Enabled = False
 CommandButton3.Caption = "データ登録"
 
 最終 = Cells(2, 9).Value
 If 最終 = 1 Then
 TextBox1.Value = 1
 Else
 TextBox1.Value = Cells(最終, 1).Value + 1
 End If
 
 Else
 
 CommandButton1.Enabled = True
 CommandButton2.Enabled = True
 CommandButton4.Enabled = True
 CommandButton3.Caption = "データ修正"
 
 Cells(1, 9).Value = Cells(2, 9).Value
 データ表示
 
 End If
 
 End Sub
 
 
 Private Sub 表示()
 With Worksheets("Database")
 表示行 = Cells(1, 9).Value
 
 TextBox1.Value = Cells(表示, 1).Value
 TextBox2.Value = Cells(表示, 2).Value
 TextBox3.Value = Cells(表示, 3).Value
 TextBox4.Value = Cells(表示, 4).Value
 TextBox5.Value = Cells(表示, 5).Value
 TextBox6.Value = Cells(表示, 6).Value
 End With
 End Sub
 
 Sub データクリア()
 
 TextBox1.Value = ""
 TextBox2.Value = ""
 TextBox3.Value = ""
 TextBox4.Value = ""
 TextBox5.Value = ""
 TextBox6.Value = ""
 
 End Sub
 
 |  |