dポイントプレゼントキャンペーン実施中!

Excel VBAで アンケート集計をしたいと思い、プログラムを作ったのですが、J列までは入力がうまくいくのですが、K列にデータを入れて次の行にデータを入れると もともと存在していたKれつのデータが消えてしまします。
どう修正すれば ちゃんとデータが残ってくれるのでしょうか?
 誰か教えてください



Option Explicit

Private Sub UserForm_Initialize()
Dim チェックボックス As Control

With cboBlood
.AddItem "A型"
.AddItem "B型"
.AddItem "O型"
.AddItem "AB型"
End With
cboBlood.ListIndex = -1

txtNo.Value = WorksheetFunction.Max( _
[Database].Resize(, 1)) + 1
txtNo.Enabled = False

txtName.Text = ""
optMale.Value = True
txtAge.Value = 0

For Each チェックボックス In fraOS.Controls
チェックボックス.Value = False
Next

txtName.SetFocus

End Sub

Private Sub cmdEntry_Click()
Dim 行 As Long
Dim 確認 As Integer

確認 = MsgBox("データを登録します。" _
& "よろしいですか?", vbYesNo)
If 確認 <> vbYes Then Exit Sub

行 = [Database].Rows.Count + 1
[Database].Cells(行 - 1, 1).EntireRow.Insert
[Database].Offset(行 - 1).Resize(1).Copy _
[Database].Cells(行 - 1, 1)
[Database].Offset(行 - 1).Resize(1).ClearContents

[Database].Cells(行, 1) = txtNo.Value
[Database].Cells(行, 2) = txtName.Text
If optMale.Value = True Then
[Database].Cells(行, 3) = "男性"
Else
[Database].Cells(行, 3) = "女性"
End If
[Database].Cells(行, 4) = cboBlood.Text
[Database].Cells(行, 5) = txtAge.Value
If chkWin.Value = True Then _
[Database].Cells(行, 6) = "○"
If chkMac.Value = True Then _
[Database].Cells(行, 7) = "○"
If chkLinux.Value = True Then _
[Database].Cells(行, 8) = "○"
If chkOther.Value = True Then _
[Database].Cells(行, 9) = "○"
If chkOther.Value = True Then _
[Database].Cells(行, 10) = "○"
Unload frmNew
End Sub

Private Sub cmdCancel_Click()
Unload frmNew
End Sub

A 回答 (1件)

列Jが10列目、列Kは11列目。


VBA中に"10"はあるが、"11"が見当たらない。

もう一度、やりたいことを整理して。
    • good
    • 0
この回答へのお礼

了解しました ありがとうございます

お礼日時:2013/02/16 12:58

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!