R
ryasportscience
Hi -
looking for a bit of guidance please. I am using a Userform to enter data into a database. Each database entry is entered as a new row and I have beenusing the following VBA code to specify the column and then find the next empty row to enter the data in.
I am trying (with not much success) to alter the code so that it finds the column header rather than specifying the column using RowCount - this is sothat if the database changes (I.e. a column added to somewhere in the middle) that the data will still be entered in the correct location.
In the example code below the first offset enters data into column A titled"Test Date"; offset 2 enters to column B titled "Test Time"; offset 3 enters to column C titled "name".
'Offset function to find the next blank cell from A1 for data inputs
RowCount = Worksheets("Data").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Data").Range("A1")
.Offset(RowCount, 0) = CDate(Me.txtTestDate.Value)
.Offset(RowCount, 1) = Me.ComboTime.Text
.Offset(RowCount, 2) = Me.txtName.Value
Thanks in advance
looking for a bit of guidance please. I am using a Userform to enter data into a database. Each database entry is entered as a new row and I have beenusing the following VBA code to specify the column and then find the next empty row to enter the data in.
I am trying (with not much success) to alter the code so that it finds the column header rather than specifying the column using RowCount - this is sothat if the database changes (I.e. a column added to somewhere in the middle) that the data will still be entered in the correct location.
In the example code below the first offset enters data into column A titled"Test Date"; offset 2 enters to column B titled "Test Time"; offset 3 enters to column C titled "name".
'Offset function to find the next blank cell from A1 for data inputs
RowCount = Worksheets("Data").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Data").Range("A1")
.Offset(RowCount, 0) = CDate(Me.txtTestDate.Value)
.Offset(RowCount, 1) = Me.ComboTime.Text
.Offset(RowCount, 2) = Me.txtName.Value
Thanks in advance