0

フィールドから列A、B、Cにデータを送信するユーザーフォームがありますが、ユーザーが送信を押すたびに、下に移動して次の空の行に入力する必要があります。

これは私が今のところ持っているものです、それを作るために何を入れるのかわからないので、A2 / B2/C2からA3/B3/C3などになります。

Private Sub Submit_Click()
   Dim LastRow As Object

   Set LastRow = Sheet1.Range("a65536").End(xlUp)

   Sheet1.Range("A2").Value = MatchNum.Text
   Sheet1.Range("B2").Value = TeamNum.Text
   Sheet1.Range("C2").Value = AllianceTeamNum.Text

   MsgBox "One record written to Sheet1"

End Sub

私はVisualBasicの完全な初心者(約1時間の経験)であり、ソリューションが可能な限り単純であるとよいでしょう。どんな助けでも大歓迎です!

4

2 に答える 2

3

以下のコードを試してください:

Private Sub Submit_Click()
    With Sheet1
        .Select

        Dim LastRow As Long
        LastRow = .Range("A65536").End(xlUp).Row + 1

        .Range("A" & LastRow).Value = MatchNum.Text
        .Range("B" & LastRow).Value = TeamNum.Text
        .Range("C" & LastRow).Value = AllianceTeamNum.Text

    End With
    MsgBox "One record written to Sheet1"

End Sub
于 2013-03-13T04:25:45.717 に答える
-1

これを試して:

Dim start As Integer

Private Sub CommandButton1_Click()

   Dim LastRow As Object

   Set LastRow = Sheet1.Range("a65536").End(xlUp)

   Sheet1.Range("A" & start).Value = "a"
   Sheet1.Range("B" & start).Value = "b"
   Sheet1.Range("C" & start).Value = "c"

   MsgBox "One record written to Sheet1"

   start = start + 1

End Sub

Private Sub UserForm_Initialize()
   start = 2
End Sub
于 2013-03-13T02:15:47.927 に答える