title: How to eliminate sub or function not defined error in VBA
body: <p>I have written this VBA code in excel, and while saving it in this workbook, I am getting <strong>sub or function not defined</strong> error and the offset line is highlighted. I am entirely new to VBA and I don't know to debug this, please help me out with this.</p>
  <p>Thanks</p>
  <pre><code>Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
  Cancel As Boolean)
  
  '######################################################################################
  'Employee Name Validation Started
  '######################################################################################
  Activate
  Range(&quot;B2&quot;).Select
  exceptionCount = 0
  Do Until ActiveCell.Address = &quot;$B$10&quot;
  ' Check if the Employee Name is Not Null
  If IsEmpty(ActiveCell.Value) Then
  totalExceptions = 1
  exceptionCount = 1
  Interior.ColorIndex = 6 'Highlight with Yellow Color
  Else
  Interior.ColorIndex = 15 'Retain Grey Color
  End If
  Offset(1, 0).Select
  Loop
  If exceptionCount = 1 Then
  exceptionString = exceptionString + vbCrLf &amp; &quot;- Employee Name Cannot be Empty&quot;
  End If
  '#######'Employee Name Validation Completed '##############################################
  
  
  End Sub
  </code></pre>