Bug 141758 - vba NumberFormat for dates does only work once and never again
Summary: vba NumberFormat for dates does only work once and never again
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.3.0.4 release
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisectRequest, regression
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2021-04-19 09:15 UTC by Harald Langheinrich
Modified: 2025-05-21 03:12 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
sub RunThis is inthis file (9.08 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-07-08 20:41 UTC, Harald Langheinrich
Details
sub RunThis is in his file (8.88 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-07-08 21:21 UTC, Harald Langheinrich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Langheinrich 2021-04-19 09:15:54 UTC
Description:
REM  *****  BASIC  *****
Option VBASupport 1
Option Compatible
Option explicit

Sub Datum()
  Dim s_tmp As String, d_date As Date


  s_tmp = InputBox("Plaese insert date :-)", _
                  "Inputbox")
  'check date or string
  If IsDate(s_tmp) Then
    'String into date format
    d_date = s_tmp
    'set Format set Date
    Range("A1").NumberFormat = "dd/mm/yyyy;@"
    Range("A1").Value = d_date
  Else
    'no date insert String 
    Range("A1").NumberFormat = "@"
    Range("A1").Value = s_tmp
  End If
End Sub

Steps to Reproduce:
1.run example twice
2.
3. and enter date for a second time

Actual Results:
runtime error 1

Expected Results:
no error 


Reproducible: Always


User Profile Reset: No



Additional Info:
[Information automatically included from LibreOffice]
Locale: de
Module: BasicIDE
[Information guessed from browser]
OS: Linux (All)
OS is 64bit: yes
Comment 1 Xisco Faulí 2021-04-22 09:48:34 UTC
Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided.
(Please note that the attachment will be public, remove any sensitive information before attaching it. 
See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
Comment 2 Harald Langheinrich 2021-07-08 20:41:03 UTC
Created attachment 173464 [details]
sub RunThis is inthis file

sub RunThis calls two times sub Datum

first time witout error 
second time with error

Why ?
Comment 3 Harald Langheinrich 2021-07-08 21:21:15 UTC
Created attachment 173465 [details]
sub RunThis is in his file

NumberFormat works when entering no date
Comment 4 Buovjaga 2021-07-19 16:11:53 UTC
(In reply to Harald Langheinrich from comment #3)
> Created attachment 173465 [details]
> sub RunThis is in his file
> 
> NumberFormat works when entering no date

If I enter a date in the format dd.mm.yyyy, I get the error immediately and nothing is inserted.

If I enter a date in the format dd/mm/yyyy it works fine both times.

The macro code looks correct (I could be wrong), so let's set to NEW.

NixOS
Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: b1df9c67349cf4cc5be4128d797aefb87f50e38f
CPU threads: 16; OS: Linux 5.13; UI render: default; VCL: x11
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Comment 5 Buovjaga 2021-08-10 18:32:22 UTC
Already seen in oldest of 6.3 bibisect repo, but not yet in latest of 5.0
Comment 6 raal 2021-08-26 15:29:21 UTC
No error in Linux bibisect-44max master, but I get error in bibisect-50max oldest.
Comment 7 Nigel Lee 2022-06-05 13:53:42 UTC
The isdate() function recognises a date entered in dd/mm/yyyy format, but not another cell which adds 1 (day) to that date, which is returned as a number.
(I creted a calendar in Excel, which uses a combination of formulae and formatting to determine subsequent date values by adding 1 (day) or 7 (week) for sequencial rows and columns.
I added code to scan the sheet and compare dates against a list of events (e.g. birthdays) from another sheet, to automatically fill in details in the corresponding position (each 'day' is made up of 3 rows).
It works fine in Excel, but fails in Libre Office VBA, because I use isdate() to skip values before the start, and beyond the end, of the month, and it doesn't recognise a numeric date value!
Comment 8 QA Administrators 2025-05-21 03:12:01 UTC
Dear Harald Langheinrich,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug