PDA

View Full Version : Entering data in next empty row



sharky12345
08-23-2010, 02:30 AM
I know someone is going to come up trumps with the answer!

I have a userform where people enter data, then that data is entered into the next empty row on the worksheet.

I've worked out the code as below;

Private Sub CommandButton12_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Data")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
ws.Cells(iRow, 3).Value = Me.txtrms1.Value
ws.Cells(iRow, 4).Value = Me.txttimeon1.Value
ws.Cells(iRow, 5).Value = Me.txttimeoff1.Value
ws.Cells(iRow, 6).Value = Me.txtcomments1.Value
ws.Cells(iRow, 3).Value = Me.txtrms2.Value
ws.Cells(iRow, 4).Value = Me.txttimeon2.Value
ws.Cells(iRow, 5).Value = Me.txttimeoff2.Value
ws.Cells(iRow, 6).Value = Me.txtcomments2.Value
ws.Cells(iRow, 3).Value = Me.txtrms3.Value
ws.Cells(iRow, 4).Value = Me.txttimeon3.Value
ws.Cells(iRow, 5).Value = Me.txttimeoff3.Value
ws.Cells(iRow, 6).Value = Me.txtcomments3.Value

Here's the problem - what I want the form to do is to enter the data from the 'txt1' boxes into the first empty row and then the data from the 'txt2' boxes into the next row, after the '1' data, and so on.

I can't work out how to do this - can anyone help?

GTO
08-23-2010, 02:48 AM
Cross-posted: http://www.mrexcel.com/forum/showthread.php?t=490010

Sharky,

Please read here: A message to forum cross posters (http://www.excelguru.ca/node/7)

Not posting a link to any other threads/sites that you already have the question posted, wastes our time in quite possibly duplicating others already made good efforts, in this case, Smitty's.

I see that you just joined, and let me be the first to welcome you here :-) Please don't take the advisement re cross-posting in any negative context, it is not intended as such. Please do take a minute to read Ken Puls excellent advisory.

Mark

sharky12345
08-23-2010, 02:51 AM
Sorry about that - didn't realise that I'd already posted it! I have put this question on a number of sites to increase the possibility of an answer!

Thanks!