ak47ok 发表于 2014-9-13 11:19
感谢关注、已补充说明,麻烦老师费神。谢谢!
看是不是明白了你的意思:- Sub test()
- Dim arr, d, i%, j%, ar, c As Range, c1 As Range
- Sheets("sheet1").Activate
- Set d = CreateObject("scripting.dictionary")
- Set c = Columns("m").Find(Range("a2"), SearchDirection:=1)
- Set c1 = Columns("m").Find(Range("a2"), SearchDirection:=2)
- arr = Range(c.Offset(, 1), c1.Offset(, 1).Resize(, 9))
- ar = Array("", "", "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛")
- For i = 1 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- d(arr(i, 1) & ar(j)) = arr(i, j)
- Next
- Next
- arr = Range(Range("a1"), Range("a65536").End(xlUp)).Resize(, 9)
- For i = 10 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- If d(arr(i, 1) & arr(1, j)) > arr(2, j) Then
- arr(i, j) = IIf(arr(1, j) = "丙" Or arr(1, j) = "辛", 0, 1)
- Else '相等也按下行处理
- arr(i, j) = IIf(arr(1, j) = "丙" Or arr(1, j) = "辛", 1, 0)
- End If
- Next
- Next
- Range("a1").Resize(UBound(arr), UBound(arr, 2)) = arr
- End Sub
复制代码 |