匹配上校A和B,并把答案放在C中

对于一个项目,我期望比较Col.A和Col.A. 我已经使用代码添加了数字,但无法找出如何比较Col.C中的两个例子,如果Col.A和Col B匹配,我想让Col.C说“是”或“否”。 也如果我想用代码做这个,而不是数字,我会添加只是string,而不是int? 或者如果我想匹配date。 任何帮助是伟大的,因为我只是回到VB

我已经在下面的代码

Private Sub CommandButton1_Click() Cells.ClearContents Range("A1") = "Column A" Range("B1") = "Column B" Range("C1") = "Column C" Dim i As Boolean For i = 2 To 25 Range("A" & i) = Int((10 - 2 + 1) * Rnd + 2) If i < 26 Then Range("B" & Range("B" & Rows.Count).End(xlUp).Row + 1) = _ Int((10 - 2 + 1) * Rnd + 2) End If Next i End Sub 

你可以使用Excel的内置确切的function?

 FormulaR1C1 = "=EXACT(RC[-2],RC[-1])" 

该函数将返回值TRUE或FALSE

FormulaR1C1片段之前,您需要input公式的目标单元格

RC[-2],[RC-1]表示对单元执行“精确”计算:向左移1格,向左移2格