+ Reply to Thread
Results 1 to 7 of 7

Logging sheet and date formula didn't work, and i believe it could be a bug in Excel

  1. #1
    Registered User
    Join Date
    10-15-2017
    Location
    kanata, ontario, canada
    MS-Off Ver
    MS 365
    Posts
    37

    Logging sheet and date formula didn't work, and i believe it could be a bug in Excel

    Description - 2 sheets
    sheet 1 - Enter the year - aka: 2018
    Cell: B1 = 2018
    ---------------------------------------------------------------
    Sheet 2 - January - 2 lines per day (see attachment for description)

    here's the formula in A3
    =Main!B1 & "-01-01" - which comes out as 2018-01-01
    Next line- A4
    =SUM(A3) - Should be 2018-01-01 but comes up as 1900-01-00


    Now to fix this, I did the following for A4
    =SUM(A3+1)-1 - which gives me 2018-01-01

    Can someone explain what happened here, or if not, is this really a bug in Excel? I'm just curious about this.

    Thank you for your cooperation.
    Attached Files Attached Files

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Logging sheet and date formula didn't work, and i believe it could be a bug in Excel

    hi there. doing a ampersand (&) to combine any numbers or texts will result in the cell turning into a text. Excel recognises dates as integers & time as decimals. to verify, type in 1jan2013 in A1. and 12 pm in B1. Format both cells to General. you will see that A1 is 41275 (meaning 41,275th day from 1 Jan 1900) & B1 is 0.5 (1/2 a day).

    hence, doing this formula below converts it into a text:
    =Main!B1&"-01-01"

    you can convert it back into a date by doing these alternatives:
    =--(Main!B1&"-01-01")
    =Main!B1&"-01-01"+0
    =Main!B1&"-01-01"*1
    =DATEVALUE(Main!B1&"-01-01")

    but again, it's pretty risky as it's based on your computer region settings. a safer option is:
    =DATE(Main!B1,1,1)

    not sure what you want in cell A4, but SUM of a text is 0. it's 0 Jan 1900. the reason why your alternative works by adding and subtracting is same as me doing the double negations, +0, or *1. it will convert any numbers in text form into a number.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Contributor
    Join Date
    06-30-2015
    Location
    Netherlands
    MS-Off Ver
    2013 / 2016 / 365
    Posts
    145

    Re: Logging sheet and date formula didn't work, and i believe it could be a bug in Excel

    Hi,

    This is not a bug but just basic excel functionality.
    Excel basic function is to do math hence it will always try to handle any operation as a math operation.
    As you have formatted your cell as text; excel can't handle the math because of the alphanumerical character of the cell.
    There are two easy ways to have Excel treat the text as a numerical to do the math.
    1. The first onbe is to convert the text with a function, called VALUE
    2. The second one is by adding a number to the text, like you did. If you want to pursue this way, better to pick 0 to add instead of 1. As adding 1 means you need to subtract 1 to have the correct result.
    HtH,

    Joris

    --------------------------------------------------------------------------------
    If you found my answer helpful, please hit the Like or Thank button.

    Please follow the forum Rules and Guidelines and use Code tags around your VBA code.

    Remember: test VBA code always on a copy of your file because usually you can't use undo

  4. #4
    Registered User
    Join Date
    10-15-2017
    Location
    kanata, ontario, canada
    MS-Off Ver
    MS 365
    Posts
    37

    Re: Logging sheet and date formula didn't work, and i believe it could be a bug in Excel

    benishiryo

    the sum is to copy the info from the cell above.

    is there a better way of doing it?

    Thanks for your explanation. My fault, didn't know that this was the reason. Now , I l know.
    Last edited by boninm; 10-30-2017 at 05:03 AM.

  5. #5
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Logging sheet and date formula didn't work, and i believe it could be a bug in Excel

    how about just:
    =A3

    SUM is normally used to add a range of cells. so rather than doing =A1+A2+A3+A4+A5, you can use =SUM(A1:A5)
    so even some of your calculation isn't necessary for SUM. for eg. =SUM(A4+1). =A4+1 is sufficient.

    hope that answers your questions. do mark as "Solved" if it does. Joris in post #4 has also chipped in, so do spend some time to see how each contribution helps you.

  6. #6
    Registered User
    Join Date
    10-15-2017
    Location
    kanata, ontario, canada
    MS-Off Ver
    MS 365
    Posts
    37

    Re: Logging sheet and date formula didn't work, and i believe it could be a bug in Excel

    Thanks Joris. Good info

  7. #7
    Registered User
    Join Date
    10-15-2017
    Location
    kanata, ontario, canada
    MS-Off Ver
    MS 365
    Posts
    37

    Re: Logging sheet and date formula didn't work, and i believe it could be a bug in Excel

    Thanks for the info.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 02-09-2016, 04:34 AM
  2. [SOLVED] Sequential PO# didn't work
    By KG869 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2015, 05:08 PM
  3. [SOLVED] Need Help with making Inventory Sheet: Removing items and logging the date
    By petg in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-02-2015, 05:22 PM
  4. my vba cursor didn't work...any help pls...
    By reignkystar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-17-2013, 01:50 AM
  5. Replies: 5
    Last Post: 01-06-2012, 08:00 PM
  6. Didn't work ( moving formula/cell )
    By Brenda in forum Excel General
    Replies: 7
    Last Post: 11-20-2005, 06:35 PM
  7. [SOLVED] Suggested answers didn't work
    By scratching my head in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-01-2005, 05:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1