【问题标题】:OpenOffice Compare two cell stringsOpenOffice 比较两个单元格字符串
【发布时间】:2014-09-05 02:23:41
【问题描述】:

所以我正在使用 Basic 中的宏,而我现在需要比较两列的重复项。

这是我到目前为止所做的:

for i = 0 To 5
   Cell1 = Sheet.getCellByPosition(0,i)

   for j = 0 to 5
   Cell2 = Sheet.getCellByPosition(1,j)

   rem COMPARISON WOULD HAPPEN HERE

   Next j
Next i

我想做一些类似的事情:if Cell1.String == Cell2.String then ...

这是我第一次尝试编写宏,因此我非常感谢任何帮助和/或指导。

谢谢!

另外,如果有人知道除 wiki 之外的其他优秀教程.文档,我将非常感谢链接

【问题讨论】:

    标签: macros openoffice.org openoffice-calc basic


    【解决方案1】:

    您应该将第一列的所有值存储到一个数组中,然后使用简单的递归将第二列的每个值与数组的所有条目进行比较。

    一个可行的代码是

    Dim firstcolumn(5) As String
    
    For i = 0 to 5
       firstcolumn(i) = Sheet.getCellByPosition(0,i)
    Next i
    
    For j = 0 to 5
       Cell2 = Sheet.getCellByPosition(1,j)
       for i = 0 to 5
        if Cell2 = firstcolumn(i) then
            MsgBox("The value of the cell " + i + " in the first column is the same with the value of the cell " + j + " of the second column")
        Next i   
    Next j
    

    查找代码示例的最佳位置是 openoffice 论坛https://forum.openoffice.org/en/forum/

    希望以上内容对你有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-29
      • 1970-01-01
      • 2019-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多