Bug 58849 - Macros: VBA code - create automatically a new row - does not work in LibreOffice
Summary: Macros: VBA code - create automatically a new row - does not work in LibreOffice
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
(earliest affected) release
Hardware: Other Windows (All)
: medium normal
Assignee: Not Assigned
Whiteboard: BSA
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
Reported: 2012-12-29 05:39 UTC by luc
Modified: 2022-03-18 11:18 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:

the spreadsheet with the VBA-code (20.50 KB, application/vnd.ms-excel)
2012-12-29 05:39 UTC, luc

Note You need to log in before you can comment on or make changes to this bug.
Description luc 2012-12-29 05:39:01 UTC
Created attachment 72233 [details]
the spreadsheet with the VBA-code

Problem description: 

In MS-Excel I ‘m using a spreadsheet with a VBA-code (which I did not create myself) whereby automatically a row is created under the row where data is inserted when, in column B, I insert whether “i” or “u” (without the brackets). The code is :

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rij As Integer, Kolom As Integer
Dim Waarde As String

  Rij = Target.Row
  Kolom = Target.Column

  If Kolom = 2 Then
    Application.ScreenUpdating = False
    Waarde = UCase(Trim(Target.Value))
    If Waarde = "I" Or Waarde = "U" Then
       Application.CutCopyMode = False
       Rows(Rij & ":" & Rij).Select
       Selection.Insert Shift:=xlDown
       Rows(Rij + 1 & ":" & Rij + 1).Select
       Selection.PasteSpecial Paste:=xlPasteAllExceptBorders, Operation:=xlNone, _
           SkipBlanks:=False, Transpose:=False
       Range("C" & Rij).Select
       Application.CutCopyMode = True
    End If
    Application.ScreenUpdating = True
  End If

(Some translations because the code is in Dutch : "Rij" = Row / "Kolom" = Column / "Waarde" = Value)

The reason for this code :

- always leave two rows open/blank between the row where data is being inserted and the sum/total of the columns F and G

- lowering the sum/totals in F and G automatically so I don’t have to create a row manually (“Insert Row”) to maintain two open/blank rows.

In LibreOffice this VBA-code works almost. (first the security for macro’s has to be set to low via extra/libreoffice/security).

When I insert “i” or u” the new row is created underneath but all the inserted data (a date in column A and “i” or “u” in column B) is deleted.

I already mentioned this problem to the developers at Novel Gooo and the were about to fix it but then this project was discontinued.

For me solving this problem is absolutely necessary to abandon MS.

Does anyone has a solution ?

Steps to reproduce:
1. ....
2. ....
3. ....

Current behavior:

Expected behavior:

Operating System: Windows XP
Version: release
Comment 1 Michel Rudelle 2013-01-22 12:35:12 UTC
I reproduce with the attached file:
The behavior does not complies with what we have with Excel 2003
Checked with:
Version (Build ID: 2ef5aff) - Vista
Microsoft Excel 2003 SP3 - Vista

Notice that with LibreOffice, we obtain a better result:
The data is no more deleted
The only difference I noticed is that the format is not reproduced on the row inserted.
Checked with:
Version (Build ID: 527dba6f6e0cfbbc71bd6e7b88a52699bb48799) - Vista
Comment 2 QA Administrators 2015-02-19 15:46:24 UTC Comment hidden (obsolete)
Comment 3 Buovjaga 2015-03-08 18:55:53 UTC
Confirmed loss of formatting (Date) in A4 after row insertion through macro.

Win 7 Pro 64-bit, LibO Version:
Build ID: 45e2de17089c24a1fa810c8f975a7171ba4cd432
Locale: fi_FI
Comment 4 tommy27 2016-04-16 07:27:13 UTC Comment hidden (obsolete)
Comment 5 QA Administrators 2017-05-22 13:23:52 UTC Comment hidden (obsolete)
Comment 6 QA Administrators 2020-11-01 04:19:42 UTC Comment hidden (obsolete)
Comment 7 Timur 2022-03-18 11:18:32 UTC
Seems like a record (not macro record but time record).
It was bug in 3.6 that was resolved in 4.0 and but left there 9 years.
Original macro just copies format, which LO also does, no date.