Description: Cells with an average formula and formatted as #,##0.000%;[RED]-#,##0.000% are in some cases changed to 0.00% format (11) upon calculation. Steps to Reproduce: 1. Manually format A1:B2 as -12.950%; #,##0.000%;[RED]-#,##0.000% 2. Run the included macro (Sub Main) Actual Results: B1 is formatted as -12.95%; Format Code: 0.00% (11) Expected Results: B1 format should remain unchanged as -12.950%; Format Code: #,##0.000%;[RED]-#,##0.000% Reproducible: Always User Profile Reset: No Additional Info: Sub Main Dim nformat As Long With ThisComponent.Sheets(0) nformat=.getCellRangeByName("B1").NumberFormat ThisComponent.EnableAutomaticCalculation(False) .getCellRangeByName("A:B").ClearContents(1023) ' all formats are removed! .getCellRangeByName("B1").setFormula("=AVERAGE(A1:A2)") .getCellRangeByName("A1").setValue(0.50) .getCellRangeByName("A2").setValue(0.6667) .getCellRangeByName("A1:B2").NumberFormat=nformat ' restore formats A1:B2 MsgBox "Format before calculation:" & .getCellRangeByName("B1").NumberFormat ThisComponent.EnableAutomaticCalculation(True) MsgBox "Format after calculation:" & .getCellRangeByName("B1").NumberFormat End With End Sub Version: 7.5.2.2 (X86_64) / LibreOffice Community Build ID: 53bb9681a964705cf672590721dbc85eb4d0c3a2 CPU threads: 8; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win Locale: en-US (en_US); UI: en-US Calc: threaded
Created attachment 186423 [details] Calc Spreadsheet with macro demonstrating bug