返回列表 上一主題 發帖

[發問] 再對比不相同的資料

[發問] 再對比不相同的資料

對比不相同的資料,不相同用紅色表示,同時在remark test2009.zip (4.6 KB) 注明,請問老師怎麼寫??

本帖最後由 kimbal 於 2010-7-29 02:02 編輯

回復 1# john2006168
  1.         Dim ci, msg
  2.     If [e2] = "" Then
  3.         Exit Sub
  4.     End If
  5.    
  6.     For i = 1 To Range("E1").End(xlDown).Row
  7.         If Range("E1").Offset(i) <> Range("E1").Offset(i, 2) Then
  8.             msg = "不相符 (miss)"
  9.             ci = 3
  10.         Else
  11.             msg = ""
  12.             ci = 0
  13.         End If
  14.         With Range("E1")
  15.             .Offset(i, 1) = msg
  16.             .Offset(i, 3) = msg
  17.             Range(.Offset(i), .Offset(i, 3)).Interior.ColorIndex = ci
  18.         End With
  19.     Next
複製代碼
懂得發問,答案就會在其中

今日の一秒は  明日にない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

回復 1# john2006168
  1. Sub Ex()
  2.     Dim i
  3.     For i = 2 To Range("E1").End(xlDown).Row
  4.         With Range("E1")
  5.             If .Cells(i, 1) = .Cells(i, 3) Then
  6.                 .Cells(i, 1).Resize(, 4).Interior.ColorIndex = 0
  7.             Else
  8.                 .Cells(i, 2) = "不相符(miss)"
  9.                 .Cells(i, 4) = "不相符(miss)"
  10.                 .Cells(i, 1).Resize(, 4).Interior.ColorIndex = 3
  11.         End If
  12.         End With
  13.     Next
  14. End Sub
複製代碼

TOP

        靜思自在 : 謊言像一朵盛開的鮮花,外表美麗,生命短暫。
返回列表 上一主題