View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
inbound03 inbound03 is offline
external usenet poster
 
Posts: 1
Default What's wrong with my NextRow code?

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/