Hello!
I try to write macro in Libre Office Macro. I want to delete data by using Libre Office Macro. How can I write this code? Can you help me?
My code is here:
Sub CopyPasteworking
xA = CreateUnoStruct("com.sun.star.table.CellAddress")
yA = CreateUnoStruct("com.sun.star.table.CellAddress")
xA1 = CreateUnoStruct("com.sun.star.table.CellAddress")
xA2 = CreateUnoStruct("com.sun.star.table.CellAddress")
yA1 = CreateUnoStruct("com.sun.star.table.CellAddress")
yA2 = CreateUnoStruct("com.sun.star.table.CellAddress")
x2a = CreateUnoStruct("com.sun.star.table.CellAddress")
y2a = CreateUnoStruct("com.sun.star.table.CellAddress")
With xA
.Sheet = 0
.Column = 0
.Row = iCount6
End With
With xA1
.Sheet = 0
.Column = 1
.Row = iCount6
End With
With xA2
.Sheet = 0
.Column = 2
.Row = iCount6
End With
With yA
.Sheet = 2
.Column = 0
.Row = iCount6
End With
With yA1
.Sheet = 2
.Column = 1
.Row = iCount6
End With
With yA2
.Sheet = 2
.Column = 2
.Row = iCount6
End With
With x2a
.Sheet = 0
.Column = 0
.Row = iCount6
End With
With y2a
.Sheet = 0
.Column = 1
.Row = iCount6
End With
For iCount6 = 0 to 6
dim document as object
document = ThisComponent
sheet1 = document.sheets(0)
sheet2 = document.sheets(1)
sheet3 = document.sheets(2)
for iCount7 = 0 to 6
if sheet1.getCellByPosition(0,iCount6).String = sheet2.getCellByPosition(0,iCount7).String then
xA.Row = iCount6
yA.Row = iCount6
xA1.Row = iCount6
yA1.Row = iCount6
xA2.Row = iCount6
yA2.Row = iCount6
SourceCell = ThisComponent.Sheets(xA.Sheet).GetCellByPosition(xA.Column, xA.Row)
PasteCell = ThisComponent.Sheets(yA.Sheet).GetCellByPosition(yA.Column, yA.Row)
PasteCell.DataArray = SourceCell.DataArray
SourceCell = ThisComponent.Sheets(xA1.Sheet).GetCellByPosition(xA1.Column, xA1.Row)
PasteCell = ThisComponent.Sheets(yA1.Sheet).GetCellByPosition(yA1.Column, yA1.Row)
PasteCell.DataArray = SourceCell.DataArray
SourceCell = ThisComponent.Sheets(xA2.Sheet).GetCellByPosition(xA2.Column, xA2.Row)
PasteCell = ThisComponent.Sheets(yA2.Sheet).GetCellByPosition(yA2.Column, yA2.Row)
PasteCell.DataArray = SourceCell.DataArray
else
end if
Next iCount7
Next iCount6
End Sub
I try to delete data if the → sheet1.getCellByPosition(0,iCount6).String = sheet2.getCellByPosition(0,iCount7).String
I want to delete instead of copy paste because of I want to copy the data if they are the common.
And I added my libre office calc sheets.
I hope you could help mecopy paste without common data.ods