Now, I am trying to run my code and suddenly I am getting an error in my Worksheet activation line. Yesterday, it worked well without any problems. Until now I was not able to find the mistake. Please refer to the code below. I'd appreciate if anyone can give me a suggestion on how to run the code without getting an error.
For the below commandbutton I am getting the error when clicked.
Private Sub cmdsubmit_Click()
Dim i As Integer
Dim Submittedtask As String
Worksheets("Submittedtask").Activate 'this line i am getting error
'position cursor in the correct cell A8.
ActiveSheet.Range("A8").Select
i = 1 'set as the first ID
'validate first three controls have been entered...
If Me.txtProject.Text = Empty Then 'Firstname
MsgBox "Please enter firstname.", vbExclamation
Me.txtProject.SetFocus 'position cursor to try again
Exit Sub 'terminate here - why continue?
End If
'if all the above are false (OK) then carry on.
'check to see the next available blank row start at cell A2...
Do Until ActiveCell.Value = Empty
ActiveCell.Offset(1, 0).Select 'move down 1 row
i = i + 1 'keep a count of the ID for later use
Loop
'Populate the new data values into the 'Data' worksheet.
ActiveCell.Value = i 'Next ID number
ActiveCell.Offset(0, 2).Value = Me.txtProject.Text 'set col B
ActiveCell.Offset(0, 3).Value = Me.txtEnia.Text 'set col C
ActiveCell.Offset(0, 1).Value = Me.DTPicker1.Value
'Clear down the values ready for the next record entry...
Me.txtProject.Text = Empty
Me.txtEnia.Text = Empty
Me.cboLs.Set Focus 'positions the cursor for next record entry
End Sub