【发布时间】:2013-09-18 13:18:49
【问题描述】:
我需要动态选择两个 excel 表的范围,并进行逐行比较,然后使用 excel VBA 宏将其打印在报表中,例如 true 或 false。请帮助。VBA Macro to compare all cells of two Excel files 这个链接很有帮助,但我想动态选择范围,还需要在比较表中打印一些 TRUE/FALSE。
我确实想将工作表加载到变体数组中,然后循环遍历它们以提高代码的性能。
注意 - 请假设需要比较的两个工作表都包含相同的行数并已排序。
For iRow = LBound(varSheetA, 1) To UBound(varSheetA, 1)
For iCol = LBound(varSheetA, 2) To UBound(varSheetA, 2)
If varSheetA(iRow, iCol) = varSheetB(iRow, iCol) Then
' Cells are identical.
' i want to go to the exact cell in Comparison sheet and type TRUE Else
' Cells are different.
' i want to go to the exact cell in Comparison sheet and type FALSE
End If
Next iCol
Next iRow
【问题讨论】:
-
所以您的问题与VBA Macro to compare all cells of two Excel files 重复。你的具体问题是什么?显示您的代码并告诉我们哪些不起作用以及您已经尝试过哪些。
-
你对代码的尝试是什么?
-
我无法在比较表中找到导航并用 TRUE/FALSE 填充每个单元格,因为我使用的变量是变体..