我正在尝试将条件格式添加到vba代码中,并且我的ISBLANK语句出现问题。
是否可以使用变量地址来定义我想检查的单元格?
这是我到目前为止所拥有的。
`Sub Employee_Training_Record()
Dim lastrow As Long
Dim lastcol As Long
If Cells(3, 2).Value = "" Then
MsgBox "No Employees in List"
GoTo gohere1:
ElseIf Cells(2, 3).Value = "" Then
MsgBox "No Training in List"
GoTo gohere1:
End If
lastrow = Cells(30, 2).End(xlUp).Row
lastcol = Cells(2, 30).End(xlToLeft).Column
employee = InputBox("Enter Employee Name")
Do While employee = ""
employee = InputBox("Enter Employee Name")
Loop
For i = 3 To lastrow
a = 0
If Cells(i, 2).Value = employee Then
GoTo gohere:
Else
a = 1
End If
Next
If a = 1 Then
MsgBox "Employee Not Found"
GoTo gohere1:
End If
gohere:
trning = InputBox("Enter Training Type")
Do While trning = ""
trning = InputBox("Enter Training Type")
Loop
For i = 3 To lastcol
b = 0
If Cells(2, i).Value = trning Then
GoTo gohere5:
Else
b = 1
End If
Next
If b = 1 Then
MsgBox "Training Not Found"
GoTo gohere1:
End If
gohere5:
exprnc = InputBox("Enter Expiration Date")
For i = 3 To lastrow
If Cells(i, 2).Value = employee Then
GoTo gohere3:
End If
Next
gohere3:
For j = 1 To lastcol
If Cells(2, j).Value = trning Then
j = j + 1
GoTo gohere4:
End If
Next
gohere4:
Cells(i, j).Value = exprnc
Cells(i, j).FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=NOW()+60"
Cells(i, j).FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Cells(i, j).FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
End With
Cells(i, j).FormatConditions(1).StopIfTrue = False
Cells(i, j).FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=NOW()"
Cells(i, j).FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Cells(i, j).FormatConditions(1).StopIfTrue = False
addrss = Cells(i, j).Address
Cells(i, j).FormatConditions.Add Type:=xlExpression, Formula1:="=ISBLANK(addrss)=True"
Cells(i, j).FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Cells(i, j).FormatConditions(1).StopIfTrue = True
MsgBox "Cell Address" & Cells(i, j).Address()
gohere1:
End Sub`