Populate cells from Macro Textbox

Loin75

Active Member
Joined
Oct 21, 2009
Messages
281
Hi, I have searched everywhere for what I think is very simple, but cannot find what I need.

Stage 1.

I have created a userform that simply has 4 textboxes on it. I would like the contents of the textboxes to populate a table in the worksheet.

Stage 2.

If the macro (userform) is used again, the data would appear on the next line of the table (rather than overwriting the first entry).

I am using Excel 2007. Is this possible?

Many Thanks for any help...
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Thank you very much, and thanks for the great link. This should do the trick.

I would like to ask though, to help me understand what it is I am typing...

What do these settings mean? What are they doing exactly?

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PartsData")

Thanks Again...
 
Upvote 0
This may help

Code:
Dim iRow As Long ' define iRow as a long integer
Dim ws As Worksheet ' define ws as a worksheet
Set ws = Worksheets("PartsData") 'assign ws - we can now use ws to refer to the sheet

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
  .End(xlUp).Offset(1, 0).Row
 
Upvote 0
I see. So if I wasn't using a seperate worksheet like in the example, do I still need to define the sheet?
 
Upvote 0
If you don't define the sheet and you use for example

Code:
Cells(iRow, 1).Value = Me.txtPart.Value

the data will be written to whichever sheet is selected when the code runs. This is fine if you are sure that the selected sheet will always be the correct one.
 
Upvote 0
There will only ever be one sheet. Thats perfect.

Thanks very much for your help...
 
Upvote 0
Hi VoG,

Sorry to go on, but i've been playing with this for the last hour, but can't get the offset to start in cell B5. No matter what I do, it always wants to populate column A.

iRow = Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 5).Row

Sorry for being lame..
 
Upvote 0
This will give you the first free (empty) row in column B

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

Forum statistics

Threads
1,214,983
Messages
6,122,588
Members
449,089
Latest member
Motoracer88

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