[英]I need to highlight a cell after a IF statement on excel vba
I need help with my code. 我的代码需要帮助。 I want after the second If statement is run I would want the row that has a "conflict" to be highlighted. 我想在第二条If语句运行后,希望突出显示具有“冲突”的行。 I have been playing with the code but I get "object required error" here is my code "This is the IF statement ` 我一直在使用代码,但是出现“对象必需错误”,这是我的代码“这是IF语句`
If (StartTime > RowStartTime) And (StartTime < RowEndTime) Or _
(RowStartTime > StartTime) And (RowStartTime < EndTime) Then
msgbox "Conflict"
ActiveCell.Select
Target.Interior.ColorIndex = 8`
Sub: 子:
Public Sub LoopRows(Appserver As String, StartTime As Date, EndTime As Date)
Dim x As Integer
Dim NumROws As Integer
NumROws = Range("Sheet3!C5").End(xlDown).Row - Range("Sheet3!C5").Row
Worksheets("Sheet3").Activate
Range("Sheet3!C5").Select
msgbox Appserver
msgbox StartTime
msgbox EndTime
For x = 1 To NumROws
ActiveCell.Offset(1, 0).Select
If (ActiveCell.Offset(0, 1).Value = Appserver) Then
Dim RowStartTime As Date
Dim RowEndTime As Date
msgbox ActiveCell.Offset(0, 1).Value
RowStartTime = Val(ActiveCell.Offset(0, 3).Value)
RowEndTime = Val(ActiveCell.Offset(0, 4).Value)
If (StartTime > RowStartTime) And (StartTime < RowEndTime) Or (RowStartTime > StartTime) And (RowStartTime < EndTime) Then
msgbox "Conflict"
ActiveCell.Select
Target.Interior.ColorIndex = 8
Application.ScreenUpdating = True
Else
msgbox "noConflict"
End If
End If
Next
End Sub
ActiveCell.EntireRow.Interior.ColorIndex = 8
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.