我有2个具有一系列值的单元格(单元格A1,B1)。 我必须比较这两个单元格,得到A1中的剩余值,输出应该在单元格C1中。 例: A1 B1 C1 23,28(0.5),29 23(0.5),27,28(0.5),29 23(0.5)
如果(0.5)为任何值,我们必须减去并显示。 我附上了样本数据。请帮忙。 我也试过下面的代码。但是有些事情出了问题,我的输出是23,29。
Function CompareDate(CommaSeparated As String, CompareString As String) As String
Dim resultString As String
resultString = CommaSeparated
For Each approvedDate In Split(CompareString, ",")
If InStr(1, resultString, approvedDate, vbTextCompare) Then
resultString = Replace(resultString, approvedDate, "")
ElseIf InStr(1, approvedDate, resultString, vbTextCompare) Then
If InStr(1, approvedDate, "0.5", vbTextCompare) Then
resultString = Replace(resultString, approvedDate, "")
End If
End If
Next
CompareDate = resultString
End Function
示例输入和输出数据: