Fix Excel VBA Writing Form Data to the Same Row
Question details
The user needs an Excel VBA data-entry form to save each submission to the next available row.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A VBA form calculates a destination row and writes form values to a worksheet.
- Observed behavior
- The macro repeatedly writes to row 2 and checks a column that does not reliably contain the submitted data.
Identify the destination worksheet and a column that is populated for every submitted record. Check the form's control names and confirm that the chosen column does not contain formulas or other content below the data table.
Use the calculated row and check a populated column
Use this approach when form submissions overwrite row 2 or the row calculation checks an empty column.
The example assumes the worksheet is named Roster, column D has a header in row 1, and TextBox1 supplies a value for column D on every submission. Change the sheet name, column number, and control names to match your form.
In Excel, open the workbook, press Alt+F11 to open the VBA editor, and open the code for the form's submit button.
Update the button's Click procedure to reference the correct sheet, check column D, and use iRow in each destination cell. For example: Private Sub CommandButton1_Click() Dim iRow As Long Dim ws As Worksheet Set ws = ThisWorkbook.Worksheets("Roster") If Trim(Me.TextBox1.Value) = "" Then MsgBox "Enter a value in TextBox1." Exit Sub End If With ws iRow = .Cells(.Rows.Count, 4).End(xlUp).Row + 1 .Cells(iRow, 4).Value = Me.TextBox1.Value .Cells(iRow, 5).Value = Me.TextBox3.Value .Cells(iRow, 6).Value = Me.TextBox4.Value End With End Sub
In the same Click procedure, change every remaining destination such as .Cells(2, 7) to .Cells(iRow, 7). Verify each Me.TextBox name against the form's control names.
Run the form and submit two test records with TextBox1 populated. Open the Roster worksheet and confirm that the records appear on consecutive rows without overwriting each other.

Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface for opening and editing spreadsheets. Its Microsoft Office format compatibility helps you move everyday workbook tasks to WPS, though it does not fix Excel VBA code.

Frequently Asked Questions
Why does my VBA form keep overwriting row 2?
The write statements may still use a hard-coded row, such as .Cells(2, 4). In the form's Click procedure, use .Cells(iRow, 4) and apply iRow to every destination cell.
Which column should I use to find the next row?
Use a column that contains a value for every record. For column D, use .Cells(.Rows.Count, 4).End(xlUp).Row + 1 inside a With block for the destination worksheet.
Why is the next row calculated far below my data?
The lookup column may contain formulas or other content below the table. Inspect that column in the destination worksheet and choose a reliably populated column without content extending below the records.
How do I check whether a text box name is correct?
In the VBA editor, open the UserForm, select the text box, and check its Name property in the Properties window. Use that exact name in the button's Click procedure.




