当colmun D获得条目“ Filled”时,我正在使用以下宏在工作表的目标记录的M(9)列中放置“ w”。
Dim lastrow As Integer
lastrow = Range("D" & Rows.Count).End(xlUp).row
'If Status is "Filled" place a "w" in Results
'Range("D2:D" & lastrow) Is the Target it defines the column D as the target area
If Not Intersect(Target, Range("D2:D" & lastrow)) Is Nothing Then
If Target <> "Filled" Then
Target.Offset(, 9) = vbNullString
Else: Target.Offset(, 9) = "w"
End If
End If
当这些记录中的任何一个记录在列表的目标行的K列中具有相同条目的所有记录的M列中,我都想输入“ w” 获取这些记录之一的列D中输入的“已填充”条目。
答案 0 :(得分:1)
我似乎没有得到答案。您的问题有点模棱两可,但这是一个主意:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range, lastRow As Long, tmpVal As Variant
lastRow = Me.Range("D" & Rows.Count).End(xlUp).Row
If Not Intersect(Target, Me.Range("D2:D" & lastRow)) Is Nothing Then
If Target.Value = "Filled" Then
tmpVal = Target.Offset(0, 7).Value
If Not Len(Trim(tmpVal)) = 0 Then
For Each cell In Me.Range("K2:K" & lastRow)
If cell.Value = tmpVal Then cell.Offset(0, 2).Value = "w"
Next cell
End If
End If
End If
End Sub