I have a timekeeping sheet that has a macro to insert a new employee and employee number. I want to apply conditional formatting to cell C10 that basically says. If the Employee number they entered was blank, highlight red. And then once they enter the 6 digit employee number it returns to no fill.
Code:
Sub New_Employee()
'
' New_Employee Macro
'
'
Dim EmployeeName As String
EmployeeName = InputBox("Enter Employee Name:" & vbCrLf & "[Firstname Lastname]", "", "")
If EmployeeName = "" Then
MsgBox "No employee was added."
Exit Sub
End If
On Error Resume Next
Dim EmployeeNumber As Variant
EmployeeNumber = InputBox("Please enter employee number.", "", "")
Rows("10:10").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B10").Value = EmployeeName
Range("C10").Value = EmployeeNumber
Range("B10").Select
ActiveWorkbook.Worksheets("Project DATA").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Project DATA").Sort.SortFields.Add Key:=Range( _
"B10"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Project DATA").Sort
.SetRange Range("B10:C999")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub