title: Excel VBA compile error: expected sub, function, or property
body: <p>I'm trying to create a code which shows the texts of name, contact person, address, contact number, email and product order onto a worksheet, but i keep getting this compile error when after entering all the information into a userform and clicking OK, note: all the coding is on the OK command button. </p>
  
  <pre><code>Private Sub cmdok_Click()
      'activate worksheet
      Worksheets("CustomersOrders").Activate
      'check if row empty
      NextRow = Application.WorksheetFunction.CountA(Range("A:A")) + 1
      Cells(NextRow, 1) = txtName.Text
      Cells(NextRow, 2) = txtperson.Text
      Cells(NextRow, 3) = txtaddress.Text
      Cells(NextRow, 4) = txtcontact.Text
      Cells(NextRow, 5) = txtemail.Text
      Cells(NextRow, 6) = txtorder.Text
  
      If optYes Then
          Worksheets("SupportInfo").Activate
          NextRow
          Application.WorksheetFunction.CountA (Range("A:A")) + 1
          Cells(NextRow, 1) = txtName.Text
          Cells(NextRow, 2) = txtperson.Text
          Cells(NextRow, 3) = txtaddress
          Cells(NextRow, 4) = txtcontact.Text
          Cells(NextRow, 5) = txtemail.Text
          Cells(NextRow, 6) = txtorder.Text
          Cells(NextRow, 7) = txtdeldate.Text
      End If
  
      'clear the controls for next entry and set focus to Name
      txtName.Text = ""
      txtperson.Text = ""
      txtaddress.Text = ""
      txtcontact.Text = ""
      txtemail.Text = ""
      txtorder.Text = ""
      txtdeldate.Text = ""
      txtName.SetFocus
  
      'hide the worksheets
      Worksheets("CustomersOrders").Visible = False
      Worksheets("SupportInfo").Visible = False
  
  End Sub
  </code></pre>