VB大虾有兴趣否,为什么CCC表第7列都是红色的.
Private Sub Command2_Click()Dim AAA As Object
Dim BBB As Object
Dim CCC As Object
Dim DDD As Object
Set AAA = CreateObject("excel.application")
AAA.Visible = True
Set BBB = AAA.Workbooks.Open("J:\H\L.xls")
Set CCC = BBB.worksheets(1)
CCC.Activate
Set DDD = BBB.worksheets(2)
DDD.Activate
Dim i, j As Integer
i = 6
For j = 5 To 27
i = 6
Do While (i <= 115)
If CCC.cells(i, 6) = DDD.cells(j, 8) Then
CCC.cells(i, 7) = DDD.cells(j, 7)
ElseIf Len(DDD.cells(j, 7).Value) = 0 Then
CCC.cells(i, 7).Value = CCC.cells(i, 6).Value
CCC.cells(i, 7).Interior.Color = RGB(255, 0, 0)
End If
i = i + 1
Loop
Next j
End Sub --------------------编程问答-------------------- 因为你的数据都满足条件
CCC.cells(i, 6) <> DDD.cells(j, 8) and Len(DDD.cells(j, 7).Value) = 0 --------------------编程问答--------------------
--------------------编程问答-------------------- 谢谢您 --------------------编程问答-------------------- 因为CCC.cells(i, 7).Interior.Color = RGB(255, 0, 0)这一句啊 --------------------编程问答-------------------- 因为CCC.cells(i, 7).Interior.Color = RGB(255, 0, 0)这一句啊 --------------------编程问答--------------------
Private Sub Command2_Click()
Dim AAA As Object
Dim BBB As Object
Dim CCC As Object
Dim DDD As Object
Set AAA = CreateObject("excel.application")
AAA.Visible = True
Set BBB = AAA.Workbooks.Open("J:\H\L.xls")
Set CCC = BBB.worksheets(1)
CCC.Activate
Set DDD = BBB.worksheets(2)
DDD.Activate
Dim i, j As Integer
i = 6
For j = 5 To 27
i = 6
Do While (i <= 115)
If CCC.cells(i, 6) = DDD.cells(j, 8) Then
CCC.cells(i, 7) = DDD.cells(j, 7)
ElseIf Len(DDD.cells(j, 7).Value) = 0 Then
CCC.cells(i, 7).Value = CCC.cells(i, 6).Value
CCC.cells(i, 7).Interior.Color = RGB(255, 0, 0) '设置第七列为红色
End If
i = i + 1
Loop
Next j
End Sub
补充:VB , VBA