我正在尝试比较2个单元格,如果它的真实行将被删除,我尝试使用msgbox返回值并显示其真实,但行未删除。 第一个单元格是使用1张中的公式导出的,另一个单元格只是数字,这是否会产生影响?
Dim r, s, i, t As Long
Dim com, cc, bl, acc As Long
Dim rDB, rInput As Range
Dim shDB, shInput As Worksheet
Set shDB = ActiveWorkbook.Sheets("Database")
Set rDB = shDB.Range("A1", "T1000")
Set shInput = ActiveWorkbook.Sheets("Data Input")
Set rInput = shInput.Range("A1", "R1000")
r = 2
Do While Len(shDB.Cells(r, 1).Formula) > 0
com = shInput.Cells(7, 5).Value
cc = shInput.Cells(5, 5).Value
bl = shInput.Cells(9, 5).Value
acc = shInput.Cells(5, 10).Value
MsgBox (com & " " & shDB.Cells(r, 1).Value & " " & cc & " " & rDB.Cells(r, 2).Value & " " & rDB.Cells(r, 3).Value & " " & bl & " " & rDB.Cells(r, 4).Value & " " & acc)
If shDB.Cells(r, 1).Value = com And rDB.Cells(r, 2).Value = cc And rDB.Cells(r, 3).Value = bl And rDB.Cells(r, 4).Value = acc Then
shDB.Rows(r).EntireRow.Delete
MsgBox ("deleting rows")
Else
r = r + 1
End If
Loop