Why doesn't LibreOffice macros record relative references... only absolute references?

When I record a macro that will “cut & paste” data entries in adjacent columns and move them to different adjacent columns in the same row (Example - “cut & paste” E2:N2 and move to D2:M2)… the macro always does EXACXTLY that. In other words, I could be at N302 when I execute the macro I recorded and the data between E2:N2 would be moved to D2:M2… NOT the data between E302:N302 moved to D302:M302.

The attached ‘.ods’ spreadsheet works properly when opened in AOO (ver4.1.4 - where it was created), but not when opened in LO (ver6.4.7.2(x64)). Working properly means: after entering a # in column N and clicking on the push button… the contents of E-N are moved to D-M and the contents of column N is cleared. Column B averages the contents of Column D-M.

AOOMacro.ods
AOOMacro.odt

(Edit: tried to fix (one hidden) downloads links -AK)

In fact the question uses the terms “relative” and “absolute” wrongly in place of “at runtime” and " at recordingtime"

You need WRITE your macros instead of recording them - if you want to work with the macros efficiently.

The reference E2:N2 is always means the cell range E2:N2 in the recorded macro code (even if it is E2:N2 or $E$2:$N$2). It never will be recalculated automatically. YOU MUST create calculated “relative” references.

You can get the SELECTED CELL RANGE for the cut & paste function, or you can SELECT the desired cell range based on the reference information of the active cell.

Thanks for the info. Although I’m self taught in using some basic formulas in a spreadsheet, I have no idea how to write/code macros. When I was using ApacheOpenOffice for this same spreadsheet I had no issues recording and running this macro.

“When I was using ApacheOpenOffice for this same spreadsheet I had no issues recording and running this macro.”

Please upload the macro code and a sample file here.
The macro recording methods of the AOO and LO are same.

I feel like a dummy. Can’t figure out how to attach files, so I can upload my “.ods” spreadsheet file from LibreOffice and a text file of the Macro as it appeared in AOO.

“I feel like a dummy. Can’t figure out how to attach files,”
Edit your question. You will find the Attachment icon at the top of the edit box.

This may be a bug in recent versions of LO Calc, but until they fix it this is a way to record a macro for relative cell reference (e.i. one that applies to any cell):

  1. Click on any empty cell in your spreadsheet.
  2. Click on Record Macro
  3. If you are using the Linux version of LO Calc proceed with clicking on any key or combination of keys, record and save your macro.
  4. If you are using Windows version of LO Calc clicking on Record Macro seems to lock the keyboard and you can only start by a.) clicking on a cell, which makes the macro an absolute refrence to that cell, or b.) clicking on a tool Icon in the tool bar (e.g. Cut, Copy, etc.). If choose B, the refence is relative to the whole work sheet (assuming you cursor was on an empty cell before you clicked on Record Macro)

(Slightly edited by @Lupp for better readability.)

In fact the question uses the terms “relative” and “absolute” wrongly in place of “at runtime” and " at recordingtime"
The actions concerning ranges of cells always are executed for the current selection by recorded macros. If you select a range during macro recording (multiselection disabled!) the range address is stored “looking absolute”. Since it isn’t changed at runtime, that’s meaningless. In fact the macro always makes a “GoTo” of that selection.
The only way to make a recorded macro “sensitive” for the CurrentSelection at runtime, is to rework it based on API usage like in ThisComponent.CurrentSelection, and to assignethe .AbsoluteName of a CellRange gotten this way to the respective argsX((n).Value.
(Recorded macros also don’t preserve the previous selection.)
If the execution of the macro for the SheetCellRange being CurrentSelection at runtime, you need to do the selecteion in advance of the recording!