I
inbound03
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.Count
' 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
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.Count
' 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