返回列表 上一主題 發帖

控制鈕輸入後換列在輸入?

控制鈕輸入後換列在輸入?

如圖請問我用控制鈕輸入在第3列後如何讓他跳下一列在第4,5,6,7,8..........列繼續輸入?

感謝回答!

111.jpg (176.9 KB)

111.jpg

程式是這樣
Private Sub Cm1_Click()

Sheets("BOB").Range("L3").Value = TextBox1.Value
Sheets("BOB").Range("B3").Value = TB3.Value
Sheets("BOB").Range("H3").Value = TB4.Value
Sheets("BOB").Range("N3").Value = TB5.Value
ActiveCell.Offset(1, 0).Select

TB3.Value = ""
TB4.Value = ""
TB5.Value = ""
TextBox1.Value = ""


End Sub

TOP

本帖最後由 lpk187 於 2015-2-13 16:28 編輯

BOBend = Sheets("BOB").Columns("L").Find("*", , , , , xlPrevious)
Sheets("BOB").Cells(BOBend + 1, "L") = TextBox1.Value
Sheets("BOB").Cells(BOBend + 1, "B") = TB3.Value
Sheets("BOB").Cells(BOBend + 1, "H") = TB4.Value
Sheets("BOB").Cells(BOBend + 1, "N") = TB5.Value

ActiveCell.Offset(1, 0).Select

TB3.Value = ""
TB4.Value = ""
TB5.Value = ""
TextBox1.Value = ""

TOP

少打了一個字,這個才對
BOBend = Sheets("BOB").Columns("L").Find("*", , , , , xlPrevious).Row
Sheets("BOB").Cells(BOBend + 1, "L") = TextBox1.Value
Sheets("BOB").Cells(BOBend + 1, "B") = TB3.Value
Sheets("BOB").Cells(BOBend + 1, "H") = TB4.Value
Sheets("BOB").Cells(BOBend + 1, "N") = TB5.Value

ActiveCell.Offset(1, 0).Select

TB3.Value = ""
TB4.Value = ""
TB5.Value = ""
TextBox1.Value = ""

TOP

BOBend = Sheets("BOB").Columns("L").Find("*", , , , , xlPrevious).Row '這行是會去找 L 欄的最後有文字的儲存格的那一列,前題是要這格每次都會輸入東西進去,若不會的話就換每次都會輸入進去的那一欄

TOP

試試+1
  1. Private Sub CommandButton1_Click()
  2.     x = Sheets("BOB").[B65536].End(xlUp).Row + 1
  3.     Cells(x, 2) = TextBox1.Text
  4.     Cells(x, 3) = TextBox2.Text
  5.     Cells(x, 4) = TextBox3.Text
  6.     Cells(x, 5) = TextBox4.Text
  7.     TextBox1.Text = ""
  8.     TextBox2.Text = ""
  9.     TextBox3.Text = ""
  10.     TextBox4.Text = ""
  11.     TextBox1.SetFocus
  12. End Sub
複製代碼

TOP

感謝lpk187大跟changxxx大!

TOP

        靜思自在 : 吃苦了苦、苦盡廿來,享福了福、福盡悲來。
返回列表 上一主題