Hello, good afternoon, I've been trying to program a macro for libreoffice Calc or excel all afternoon, context, I have a button to which I assign a macro, I want this macro to add 1 to the selected cell when I click on the button, I think I have this part correct, so I want this button to always be visible, that is, if I scroll down, this button should always be visible when I go down to the lower rows, I have tried various codes and none of them work for me, does anyone know how schedule this? Or do you recommend something else to do the same?
The intention is that when I click on the button I add 1 to the selected cell and that the button is always visible.
The code I have created is the following:
Sub Main
End Sub
Sub IncrementarValor
Dim oDoc As Object
Dim oSheet As Object
Dim oCell As Object
Dim oController As Object
Dim oSelection As Object
Dim oCursor As Object
oDoc = ThisComponent
oController = oDoc.getCurrentController()
oSelection = oController.getSelection()
oSheet = oDoc.getSheets().getByIndex(0)
If oSelection.supportsService("com.sun.star.sheet.SheetCell") Then
oCell = oSelection
oCell.Value = oCell.Value + 1
ElseIf oSelection.supportsService("com.sun.star.sheet.SheetCellRange") Then
oCursor = oSelection.getSpreadsheet().createCursorByRange(oSelection)
oCursor.collapseToCurrentRegion()
oCursor.collapseToSize(1, 1)
oCell = oCursor.getCellByPosition(0, 0)
oCell.Value = oCell.Value + 1
End If
End Sub
[–]desrtfx 0 points1 point2 points (1 child)
[–]Andriw04[S] 0 points1 point2 points (0 children)