Sub HorizonatalCompareOddEvenRows()
vSelection = ThisComponent.CurrentSelection
oSelect=ThisComponent.CurrentSelection.getRangeAddress
oSelectColumn=ThisComponent.CurrentSelection.Columns
oSelectRow=ThisComponent.CurrentSelection.Rows
CountColumn=oSelectColumn.getCount
CountRow=oSelectRow.getCount
oSelectSC=oSelectColumn.getByIndex(0).getName
oSelectEC=oSelectColumn.getByIndex(CountColumn-1).getName
oSelectSR=oSelect.StartRow+1
oSelectER=oSelect.EndRow+1
NoCell=(CountColumn*CountRow)
If CountColumn=1 AND CountRow=1 Then
MsgBox("Cell " + oSelectSC + oSelectSR + chr(13) + "Cell No = " + NoCell,, "SelectedCells")
Else
MsgBox("Range(" + oSelectSC + oSelectSR + ":" + oSelectEC + oSelectER + ")" + chr(13) + "Cell No = " + NoCell,, "SelectedCells")
End If
colorArray = Array(RGB(255,141,6), RGB(255,141,36), RGB(255,141,66), RGB(255,141,96), RGB(255,141,126))
colorAraySize = UBound(colorArray)
For colIndex = 0 To CountColumn-1
For rowIndex = 0 To CountRow-2
If (rowIndex mod 2) = 0 Then
vSel = vSelection.GetCellbyPosition(colIndex,rowIndex)
vNext = vSelection.GetCellbyPosition(colIndex,rowIndex+1)
s = vSel.getString()
s2 = vNext.getString()
If Len(s) > 0 AND Len(s2) > 0 Then
'Print s, s2, "(",colIndex,",",rowIndex,")","(",colIndex,",",(rowIndex+1),") Comp result",StrComp( s, s2)
If StrComp(s, s2) <> 0 Then
index = rowIndex mod colorAraySize
vNext.CellBackColor = colorArray(index)
Else
'vSel.CellBackColor = RGB(255,255,255)
End If
Else
'Print "Nothing is selected"
End If
End If
Next
Next
End Sub
Tuesday, August 7, 2012
Open Office Macro Horizontal Odd-Even Row Compare
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment