PDA

View Full Version : Solved: Next Row in Spreadsheet



Kindly_Kaela
05-03-2007, 07:06 AM
Hi Everyone!

I'm trying to populate an excel spreadsheet with data entered into a form. I want to take the data and fill in the next empty row. Is there code that will determine the next empty row and fill in the data in that row?

Thanks!
Kaela

lucas
05-03-2007, 07:41 AM
http://vbaexpress.com/forum/showthread.php?t=9774

Kindly_Kaela
05-03-2007, 07:57 AM
Thanks for the quick reply Lucas. How do I adjust the following code to enter text into the next row (first empty)? Thank you!


Sub LastRow()

Sheets("DeMo").Select

If Range("A" & Rows.Count).End(xlUp) = "" Then GoTo Finish

'give the last row
MsgBox "Last row is row " & Range("A" & Rows.Count).End(xlUp).Row
Exit Sub

Finish:
MsgBox "No formulas or data found"
End Sub

lucas
05-03-2007, 08:03 AM
Three textboxes:
Private Sub CommandButton1_Click()
Dim LastRow As Object
Set LastRow = Sheet1.Range("a65536").End(xlUp)
LastRow.Offset(1, 0).Value = TextBox1.Text
LastRow.Offset(1, 1).Value = TextBox2.Text
LastRow.Offset(1, 2).Value = TextBox3.Text
End Sub

Kindly_Kaela
05-03-2007, 08:51 AM
You're the best Steve, one more quick question.

How do I make one of the entry cells today's date? ...and also, keep that date instead of it changing tomorrow.

This way I can track when entries were made.

Thanks hun!!

lucas
05-03-2007, 09:08 AM
You don't do anything....just use a label to mark it as date and go...see attached.....if you want the date to update each time it is edited then that is a different thing...

mdmackillop
05-03-2007, 09:08 AM
LastRow.Offset(1, 3).Value = Date

lucas
05-03-2007, 09:15 AM
or try this one...sheet change event

lucas
05-03-2007, 09:18 AM
Malcolms works the best and simplest......guess I'm trying to overcomplicate things..

Kindly_Kaela
05-03-2007, 11:34 AM
Thank you EVERYONE!!!