标题可能有点误导,所以这里......
在电子表格中,我需要监控Col“I”以测试其中插入的数字是否包含“22822”..它通常是22822564或22722762这样的数字。这些数字意味着如果输入22822xxx刚刚离开的单元格(在Col“H”中必须更改并显示黄色背景和文本“等待处理”
处理完集后,用户将手动将此值更改为“已处理”,然后背景col必须更改为空...
因此..用户在I33输入22822564,然后H33将显示黄色背景的“等待处理”。如果手动更改H33的内容,则删除背景颜色。
到目前为止,我已经做到了这一点并且卡住了......
任何助手?
Sub Worksheet_Change(ByVal Target As Range)
Dim WatchRange As Range
Dim IntersectRange As Range
Dim FillRange As Range
Dim IntersectFillRange As Range
Set WatchRange = Range("I1:I1110")
Set FillRange = Range("H1:H1110")
Set IntersectRange = Intersect(Target, WatchRange)
Set IntersectFillRange = Intersect(FillRange, WatchRange)
If IntersectRange Is Nothing Then
'Do Nothing
Else
On Error Resume Next
check = Application.WorksheetFunction.Search("22822", IntersectRange)
On Error GoTo 0
If check = False Then
MsgBox "String does not contain 22822"
Else:
MsgBox "Found it !!!"
IntersectFillRange.Interior.Color = RGB(200, 160, 35)
End If
End If
End Sub
答案 0 :(得分:2)
这个怎么样?
Sub Worksheet_Change(ByVal Target As Range)
Dim WatchRange As Range
Set WatchRange = Range("I1:I1110")
If Not Intersect(Target, WatchRange) Is Nothing Then
If VBA.Left$(Target, 5) = "22822" Then
Target.Offset(0, -1) = "Waiting on Processing"
Target.Offset(0, -1).Interior.Color = RGB(200, 160, 35)
End If
End If
End Sub
如果要删除颜色格式,如果有人用"Waiting on Processing"
覆盖"Processed"
,那么我只需在H1:H1110
上设置条件格式,如果单元格将背景颜色设置为白色值等于"Processed"