Userform populate data in Column B, C, D and then repeat for next row

tbush33

New Member
Joined
Oct 22, 2017
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to create a form that allows users to enter a request and then it will populate the data into the worksheet. The issue is that I have data in column A that needs to stay there, so I need the data to go to the next cell in B. For example:

[TABLE="width: 500, align: center"]
<tbody>[TR]
[TD]RFA ID[/TD]
[TD]Requested By[/TD]
[TD]Date[/TD]
[TD]Description[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]John[/TD]
[TD]12/13[/TD]
[TD]yada yada[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


In the table above I want the data from my user form to go to Columns labeled - Requested By, Date, & Description. Then for the next user to use the form, I would like it to enter their information into row 2, etc. Here is the code I have now, but it requires the cell to be selected:

Code:
Private Sub cmdSubmit_Click()

If txtName.Value = "" Then
    If MsgBox("Please enter name or type Anonymous") Then
    Exit Sub
    End If
End If
    
ActiveCell = txtName.Value
ActiveCell.Offset(0, 1) = DT1.Value
ActiveCell.Offset(0, 2) = txtDesc.Value


ActiveCell.Offset(1, 0).Select




Call resetForm


End Sub




Sub resetForm()


txtName.Value = ""
txtDesc.Value = ""
formRFA.txtName.SetFocus


End Sub

Any help on this matter would be much appreciated!!

Thanks,
Travis
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try this:
Code:
Private Sub cmdSubmit_Click()
Dim lrow As Long
If txtName.Value = "" Then
    If MsgBox("Please enter name or type Anonymous") Then
    Exit Sub
    End If
End If
lrow = Cells(Rows.Count, 2).End(xlUp).Row
Cells(lrow, 2) = txtName.Value
Cells(lrow, 3) = DT1.Vaqlue
Cells(lrow, 4) = txtDesc.Value
Unload Me
End Sub

Let me know if you have questions!
 
Upvote 0
Thanks Max! It worked, but it replaced my headers. Is there anyway that it could find the next empty row?
 
Upvote 0
So the data populates COLUMNS B,C,D but do not find the first empty row. Instead it replaced my Headers. Any chance there is a solution for that?
 
Upvote 0
Try changing this line of code:
Code:
lrow = Cells(Rows.Count, 2).End(xlUp).Row

To this:

Code:
lrow = Cells(Rows.Count, 2).End(xlUp).Row+1
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top