我正在尝试制定具有以下三个条件的Index-Match函数: 条件1:它应该只检查突出显示的单元格 条件2:应在“计划外”列中检查同一个人 条件3:不应再重复同一个人
我有两个工作表。在工作表1上,我有一张表,上面有针对员工的职位。在Sheet2上,我有一个表,其中索引匹配将适用。它还包含突出显示的单元格和下拉菜单。 代码应从下拉列表中选择名称,而不要覆盖该列表 我在两个表中都设置了命名范围。我尝试过的是以下代码。
Option Explicit
'use a constant to store the highlight color...
Const HIGHLIGHT_COLOR = 9894500 'RGB(100, 250, 150)'Is a cell highlighted?
EDIT: changed the function name to IsHighlighted
Function IsHighlighted(c As range)
IsHighlighted = (c.Interior.Color = HIGHLIGHT_COLOR)
End Function
Sub AssignBided()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim cel1 As range
Dim cel2 As range
Dim Bid As range
Dim line As range
Dim Offemp As range
Dim BidL8 As range
Dim BidL8E As range
Dim coresVal As String
Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")
Set Bid = ws2.range("Bid")
Set line = ws2.range("All_Pos_Hilight_Mon")
Set Offemp = ws2.range("Off_Mon") 'Scheduled Off Column
Set BidL8 = ws1.range("Bid_Pos") 'Bided Position
Set BidL8E = ws1.range("Bid_Emp") 'Bided Employee for a Position
For Each cel1 In BidL8E
For Each cel2 In line
If IsHighlighted(cel2) Then
If Application.WorksheetFunction.CountIf(Offemp, cel1.Value) > 0 Then
coresVal = Evaluate("Index(" & BidL8E.Address & "),MATCH(" & cel2.Validation & "," & BidL8.Address & ",0))")
Debug.Print coresVal
cel2.Offset(0, 2).Value = coresVal
End If
End If
Next cel2
Next cel1
End Sub
此代码未执行。我收到错误消息: 对象不支持此属性或方法 它突出显示了第33行。如果有人可以帮助我,将不胜感激。谢谢。