inbound03,
For your NextRow, you could use the following:
NextRow = Sheets("Recap").Range("a53").end(xlup).row + 1
That should return the last blank row underneath row 53.
Also...in your code:
'Check for completeness
If cmbConcernCargo.Text = "" Then
MsgBox "You forgot to select the security concern"
FrameConcernCargo.Visible = True
End If
You might want to add (just after the MsgBox)
Exit Sub ' so that the rest of your code won't run
John
"inbound03" wrote in message
...
I am new to VBA for Excel and hopefully some experts on the Forum can
help me solve the problem.
I try to use NextRow to insert data to the next available row and it is
not working.
The workbook has 4 worksheets. The User Form is on sheet REPORT (the
active sheet) and when user selects the “No” option button on one of
the questions in the UwerForm, a combo box appears and the data in the
combo box will be transferred to sheet RECAP starting from row D54. I
was able to transfer the data to the D column in sheet RECAP but
instead of D54, thge data was put in D55; the subsequent No answers put
the data in the wrong row as well.
Here is the code I wrote:
'Hide the combo box and the OK button after transferring respective
concern to "Recap"
Private Sub cmdCargoEnter_Click()
'Hide the frame
FrameConcernCargo.Visible = False
'Check for completeness
If cmbConcernCargo.Text = "" Then
MsgBox "You forgot to select the security concern"
FrameConcernCargo.Visible = True
End If
' Find next available row
NextRow = Sheets("Recap").Range("a53").Row + _
Sheets("Recap").Range("a53").CurrentRegion.Rows.Co unt
' Transfer the concern
Sheets("Recap").Cells(NextRow, 4) = cmbConcernCargo
' Reset the Userform for the next row
cmbConcernCargo = ""
End Sub
I attached two screenshots for reference
---
Message posted from http://www.ExcelForum.com/