Description: I expect the following macro to overwrite the value of A1 with that of B1 everytime: Sub Bugged Cells(1,1).Value=Cells(1,2).Value End Sub However, when B1 is empty, it instead does not change the value of A1. Steps to Reproduce: 1. Write these macros in BASIC: Sub Bugged Cells(1,1).Value=Cells(1,2).Value End Sub Sub Fix If Cells(1,2).Value = "" Then Cells(1,1).value="" Else Cells(1,1).value=Cells(1,2).Value End Sub 2. Fill A1 with 1 and B1 with 2, run the macros. 3. Fill A1 with 1 and leave B1 empty, run the macros Actual Results: For Step 2, both overwrite A1 with 2. For Step 3, Bugged leaves A1 at 1, while Fix makes A1 empty. Expected Results: For Step 2: Same as actual For Step 3: Bugged should also make A1 empty Reproducible: Always User Profile Reset: No Additional Info: It may be that Cells(1,2).Value returns some kind of error instead of an empty cell and the macro then cannot assign this error as a value and thus does nothing instead.
(In reply to documentfoundation.showoff307 from comment #0) > Steps to Reproduce: > 1. Write these macros in BASIC: > > Sub Bugged > Cells(1,1).Value=Cells(1,2).Value > End Sub > > Sub Fix > If Cells(1,2).Value = "" Then Cells(1,1).value="" Else > Cells(1,1).value=Cells(1,2).Value > End Sub Those macros do not run at all. Please attach a spreadsheet file, that contains macros that at least run.
Created attachment 205110 [details] MWE
Okay, apparently it needs the Option VBASupport 1 So, this is a VBA Support issue. As it was not in the specific module i tested it with before, i did not know that. minimum working example attached, unsure if the xlsm format is relevant.
The emptiness of cell B1 makes cell A1 empty on value assignment in Excel. LibreOffice does not change the value of cell A1 in this case. As VBASupport it introduced to be compatible with Excel macros, the behavior in LibreOffice should be changed to that of Excel.
Created attachment 205116 [details] Macro embedded in file Replaces previous attachment "205110: MWE" because that one does not contain any macro.
Created attachment 205117 [details] macro with VBASupport made by LibreOffice The macro Option VBASupport 1 Sub FromB1ToA1() Cells(1, 1).Value = Cells(1, 2).Value End Sub directly written in LibreOffice. The behavior was tested in Version: 25.8.4.2 (X86_64) Build ID: 290daaa01b999472f0c7a3890eb6a550fd74c6df CPU threads: 32; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win Locale: de-DE (de_DE); UI: en-US Calc: threaded