Consulting

Results 1 to 3 of 3

Thread: Entering data in next empty row

  1. #1
    Banned VBAX Regular
    Joined
    Aug 2010
    Posts
    54
    Location

    Entering data in next empty row

    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?

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Cross-posted: http://www.mrexcel.com/forum/showthread.php?t=490010

    Sharky,

    Please read here: A message to forum cross posters

    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

  3. #3
    Banned VBAX Regular
    Joined
    Aug 2010
    Posts
    54
    Location
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •