Hey everyone, sorry, my VBA is pretty limited. I am trying to create a new update form by reverse engineering a working form. I am getting error '1004' "Select method of Range class failed". The error is from "rng.Select" but I dont see anything wrong with the code where the range is defined, IDK.
As a side note, I also have time stamp to record the entry date but if possible I would like to switch that out for a date picker but I can seem to find a good way to do that. Anything obvious I might be missing or is this not an option anymore.
Code
Private Sub CommandButton1_Click()
Dim oNewRow As ListRow
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("DATA_SHEET").Range("TempTbl")
rng.Select
Set oNewRow = Selection.ListObject.ListRows.Add(AlwaysInsert:=True)
With ws
oNewRow.Range.Cells(1, 1).Value = Me.TempID
oNewRow.Range.Cells(1, 6).Value = Me.StatusC
oNewRow.Range.Cells(1, 2).Value = Now
End With
Me.TempID = ""
Me.StatusC = ""
End Sub
As a side note, I also have time stamp to record the entry date but if possible I would like to switch that out for a date picker but I can seem to find a good way to do that. Anything obvious I might be missing or is this not an option anymore.
Code
Private Sub CommandButton1_Click()
Dim oNewRow As ListRow
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("DATA_SHEET").Range("TempTbl")
rng.Select
Set oNewRow = Selection.ListObject.ListRows.Add(AlwaysInsert:=True)
With ws
oNewRow.Range.Cells(1, 1).Value = Me.TempID
oNewRow.Range.Cells(1, 6).Value = Me.StatusC
oNewRow.Range.Cells(1, 2).Value = Now
End With
Me.TempID = ""
Me.StatusC = ""
End Sub