excel vba method default of object range failed
I have an application build with Excel that throws an error, but only sporadically. The code simply takes values from a form and writes to a worksheet.
The error thrown is method default of object range failed. I've tried most of the solutions I've found on line so far and still get the error. Have tried using two different machines, and still get error. Here is the relevant code....
Private Function fnAssignValuesPCNA(lngRow As Long, lngID As Long)
On Error GoTo Err_fnAssignValuesPCNA
'Take values from the form and assign to cells on Sheet5
With Sheet5
.Cells(lngRow, 1) = lngID ' throws error at this line
.Cells(lngRow, 2) = Me.txtDate
.Cells(lngRow, 3) = Me.cbxWeek
.Cells(lngRow, 4) = Me.cbxRoomBed
.Cells(lngRow, 5) = Me.txtInitials