I currently have an Excel 2010 spreadsheet. I have designed a form and I'm looking to allow users to enter date into the form and it then be entered into the worksheet.
My first entry is "txtDate" on my form and I wish for this to be entered into cell J7 with the next data in the form "txtTime" going into cell K7 and then other data into other cells in the row - L7, M7, N7 etc etc... Once this cell is submitted with a button using on the form, the data is entered and then the next time the form is used, the data will go into the next row below, row 8 and then row 9 on the next occasion etc...
I've found the sample below code on the internet and the example shows that it starts in cell A2. I can't see mention of A2 and so I'm wondering how I edit the code to start in cell J7.
'Copy input values to sheet.
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Animals")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.cboClass.Value
.Cells(lRow, 2).Value = Me.txtGivenName.Value
.Cells(lRow, 3).Value = Me.txtTagNumber.Value
.Cells(lRow, 4).Value = Me.txtSpecies.Value
.Cells(lRow, 5).Value = Me.cboSex.Value
.Cells(lRow, 6).Value = Me.cboConservationStatus.Value
.Cells(lRow, 7).Value = Me.txtComment.Value
Here is my code dated 27/03/2015 following the answer:
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Pursue")
lRow = Application.WorksheetFunction.Max(ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row, 7)
With ws
.Cells(lRow, 10).Value = Me.dateBox.Value
etc....
Aucun commentaire:
Enregistrer un commentaire