Hi
Can anybody put me right on a 'Compile error: Sub or Function not defined' please.
Have had my first try at a userform and have copied this from the web.
The userform has many labels and text boxes and a few combo boxes. Basically i'm looking for the form to populate a table called "datastore" which is on the "datastore" tab.
i get the above error message which also highlights the phrase "offset" on row 8. Can anybody give me a clue as i've drawn a complete blank (the code im using is below).
Apologies if this has been answered a hundred times. i cannot find anything that works.
Can anybody put me right on a 'Compile error: Sub or Function not defined' please.
Have had my first try at a userform and have copied this from the web.
The userform has many labels and text boxes and a few combo boxes. Basically i'm looking for the form to populate a table called "datastore" which is on the "datastore" tab.
i get the above error message which also highlights the phrase "offset" on row 8. Can anybody give me a clue as i've drawn a complete blank (the code im using is below).
Apologies if this has been answered a hundred times. i cannot find anything that works.
Code:
Private Sub CommandButton1_Click()
'Copy input values to sheet.
Dim oNewRow As ListRow
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("Datastore").Range("datastore")
rng.Select
Set oNewRow = Selection.ListObject.ListRows.Add(AlwaysInsert:=True)
With ws
oNewRow.Range.Cells(1, 1).value = Offset(0, -1).value + 1
oNewRow.Range.Cells(1, 2).value = Me.Label2.value
oNewRow.Range.Cells(1, 3).value = Me.Label13.value
oNewRow.Range.Cells(1, 4).value = Me.TextBox1.value
oNewRow.Range.Cells(1, 5).value = Me.Label18.value
oNewRow.Range.Cells(1, 6).value = Me.Label15.value
oNewRow.Range.Cells(1, 8).value = Me.ComboBox3.value
oNewRow.Range.Cells(1, 9).value = Me.TextBox2.value
oNewRow.Range.Cells(1, 10).value = Me.ComboBox2.value
oNewRow.Range.Cells(1, 11).value = Me.Label16.value
oNewRow.Range.Cells(1, 12).value = Me.Label19.value
oNewRow.Range.Cells(1, 13).value = Me.Label15.value
oNewRow.Range.Cells(1, 18).value = Me.Label15.value
oNewRow.Range.Cells(1, 16).value = Me.Label2.value
oNewRow.Range.Cells(1, 17).value = Me.Label13.value
End With
' Clear input controls.
' Clear_create_form
End Sub
Last edited by a moderator: