How do we assign textbox to cell to continue adding data using userform?

charles2010

New Member
Joined
Mar 11, 2010
Messages
3
Hi guys,

I'm still at the learning stage on how to build userforms for data entry in my worksheet.

I already have a worksheet done up and am now trying to create a userform to speed up the data entry process. But I'm stuck because the tutorials out there only teach us how to assign the first textbox to the first column of the sheet.

How do we code the first textbox to a different cell in the worksheet and start adding data from there?

Been trying to match the textbox to a different cell but when I add new data, the new data overwrites the old data in the cell....

Please help? I'm loosing sleep on this puzzle....

To better illustrate this, here's the file...
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

rs2k

Well-known Member
Joined
Aug 15, 2004
Messages
1,413
Hi Charles, welcome to the board,

This bit of code takes 4 textboxes and puts the data in Col's A:D, and keeps adding data below. Put this code on a button on your userform;
Code:
Private Sub cmdAdd_Click()

Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

'find first row in database
irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

With ws
.Range("A" & irow) = TextBox1.Value
.Range("B" & irow) = TextBox2.Value
.Range("C" & irow) = TextBox3.Value
.Range("D" & irow) = TextBox4.Value

End With
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""

End Sub

it also clears the textboxes ready for the next entry;

HTH
Colin
 

charles2010

New Member
Joined
Mar 11, 2010
Messages
3
From here, I just need to change

"A" to my new column!

It works like a charm!

You are awesome!


Thank you!!!
 

Watch MrExcel Video

Forum statistics

Threads
1,123,295
Messages
5,600,789
Members
414,405
Latest member
Zaurb

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
Top