简体   繁体   中英

Excel VBA increasing rows/columns

http://imgur.com/zEm7hT7

In my image I have my form which upon entering information into the text boxes and pressing enter will place the information into the correct places below the titles, what i'm wanting to do is either have a next button that will go down one row and a back button that will go up one row and allows me to enter information into a 'database' per say or i would like to have it automatically jump down one row upon clicking 'Enter'. I have looked and I can't find anything that is quite what i'm asking and response is great, thanks.

This is what i have so far.

Private Sub CommandButton1_Click()
Dim x As Integer
x = Cells(1, 1).End(xlDown).Row + 1
Cells(x, 1) = TextBox1.Value
Cells(x, 2) = TextBox2.Value
Cells(x, 3) = TextBox3.Value
Cells(x, 4) = TextBox4.Value
Cells(x, 5) = TextBox5.Value
End Sub

Replace x=2 with finding the next empty row

If Cells(2,1) = "" Then
    x = 2
Else
    x = Cells(1,1).End(xlDown).Row + 1
End If

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM