In principle, it is not very difficult. Let’s do it together step by step.
Let’s write a macro first. Did you say that you had problems with this?
Actually, this should not happen with new versions of the office suite. By the way, what version and what operating system are you using?
So, choose Record Macro from the menu. Select cells C5:E5, press Backspace, specify what exactly should be cleared in these cells and press Enter, select cell C10 and stop recording. Save to the current document in Module1 with a name, for example, clearRng
. We get something like this code:
sub clearRng
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$C$5:$E$5"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Flags"
args2(0).Value = "SVDFN"
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$C$10"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
end sub
Now let’s use the trick that our esteemed colleague Lupp has repeatedly described - let’s create a hyperlink that will call the macro. Write the formula in cell A10
=HYPERLINK("vnd.sun.star.script:Standard.Module1.clearRng?language=Basic&location=document";"Reset")
That’s it, problem solved.