I have written this VBA code in excel, and while saving it in this workbook, I am getting sub or function not defined 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.
Thanks
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
'######################################################################################
'Employee Name Validation Started
'######################################################################################
Activate
Range("B2").Select
exceptionCount = 0
Do Until ActiveCell.Address = "$B$10"
' 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 & "- Employee Name Cannot be Empty"
End If
'#######'Employee Name Validation Completed '##############################################
End Sub