+ Reply to Thread
Results 1 to 6 of 6

error when subtracting time values using VBA: cell content not recognized as time

  1. #1
    Registered User
    Join Date
    12-23-2021
    Location
    Boston, USA
    MS-Off Ver
    Mac MS 365 version 16.63.1
    Posts
    57

    error when subtracting time values using VBA: cell content not recognized as time

    Hello.

    The time value in the cells in column "start.time" should be subtracted from the time value of the respective cell in column "end.time", and the result inserted in the respective cell in the next empty column, when executing the macro via a button.

    The calculation is not performed via the macro, because, I think, of the formatting of the cells in columns "start.time" and "end.time". I tried to format them as Text and Time, manually and via the macro, but the error persists. I do get the correct result, when I simply subtract the values via a formula (e.g. =B2-A2).

    Does anyone know what the issue is in the vba code?

    I attached the xlsm file. subtract_time.xlsm

    Thanks! Sophia

  2. #2
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,513

    Re: error when subtracting time values using VBA: cell content not recognized as time

    Please Login or Register  to view this content.
    "Presh Star Who has help you *For Add Reputation!! And mark case as Solve"

  3. #3
    Registered User
    Join Date
    11-04-2014
    Location
    Portugal
    MS-Off Ver
    XL2013/XL365
    Posts
    93

    Re: error when subtracting time values using VBA: cell content not recognized as time

    There is no consistency in the values, some are "TIME" others are String's

    Try this, works for me
    Format cells (Result.time) with "TIME"

    Please Login or Register  to view this content.
    Last edited by JCabral; 05-16-2024 at 07:43 AM.

  4. #4
    Registered User
    Join Date
    12-23-2021
    Location
    Boston, USA
    MS-Off Ver
    Mac MS 365 version 16.63.1
    Posts
    57

    Re: error when subtracting time values using VBA: cell content not recognized as time

    still not working. I get the below msg. Did the macro work for you?

    Attachment 869280Attachment 869281

  5. #5
    Registered User
    Join Date
    12-23-2021
    Location
    Boston, USA
    MS-Off Ver
    Mac MS 365 version 16.63.1
    Posts
    57

    Re: error when subtracting time values using VBA: cell content not recognized as time

    Not working unfortunately. Run-time error 13. Does it work for you? If so, could you provide the entire code, please?

  6. #6
    Registered User
    Join Date
    11-04-2014
    Location
    Portugal
    MS-Off Ver
    XL2013/XL365
    Posts
    93

    Re: error when subtracting time values using VBA: cell content not recognized as time

    Quote Originally Posted by cybersurfer5000 View Post
    still not working. I get the below msg. Did the macro work for you?

    Attachment 869280Attachment 869281
    This works perfect to me
    I can´t see the attached msg
    Attached Files Attached Files
    Last edited by JCabral; 05-16-2024 at 02:13 PM.

+ 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: 7
    Last Post: 08-21-2016, 10:45 PM
  2. Subtracting Values of Time
    By BillyGoatsGruff in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2016, 09:14 AM
  3. subtracting time values
    By dwinters in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-12-2015, 10:47 AM
  4. Replies: 10
    Last Post: 11-08-2014, 04:51 PM
  5. converting military time to EDT and subtracting time from one cell to another
    By niklas24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-03-2010, 09:41 AM
  6. Subtracting time values
    By fishphone in forum Excel General
    Replies: 2
    Last Post: 06-27-2005, 01:29 PM
  7. SUBTRACTING TIME VALUES INSTEAD OF DECIMAL!!
    By Lexicon in forum Excel General
    Replies: 8
    Last Post: 04-19-2005, 04:06 PM

Tags for this Thread

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