+ Reply to Thread
Results 1 to 3 of 3

Dateadd hours calculation VBA problems!

Hybrid View

  1. #1
    Registered User
    Join Date
    01-11-2015
    Location
    Manchester, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Dateadd hours calculation VBA problems!

    Can someone help me to calculate time to decimal from an whole column!
    This scrip is not working 100%. I get an error but it writes correct value when I format it into general from time.

    In column 6 I have time (like; 08:00, 23:00 etc). I want to use an dateadd "h" to control if any values are bigger then 07:00.
    So what I basicly do is:

    If DateAdd("h", 1, sheet1.Cells(I, 6)) * 24) - 7> "" Then
    I need to convert the time to decimal. If the time in column 7 is: 07:30 I want it to write:0,5 (07:30 - 07:00 (see sub in if-statement)).

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dateadd hours calculation VBA problems!

    Hi, and welcome to the forum,

    Why do you need a macro? You can probably achieve what you want with normal Excel functions.

    Upload the workbook and manually add the results you expect to see clearly explaining which cells are data and which are the results.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    01-11-2015
    Location
    Manchester, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Dateadd hours calculation VBA problems!

    Quote Originally Posted by Richard Buttrey View Post
    Hi, and welcome to the forum,

    Why do you need a macro? You can probably achieve what you want with normal Excel functions.

    Upload the workbook and manually add the results you expect to see clearly explaining which cells are data and which are the results.
    Hi and thank you so much!
    I need an macro because I have write the whole script in VBA and this is the last things I need to get done to have an fully working script. I can't upload the whole file because of privacy data in the file - hope you understand.

    Just want this vba scrip run without any probs.

    Thank you!

+ 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. DateAdd/DateDiff problem
    By LarsP in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2013, 05:30 AM
  2. [SOLVED] dateAdd Overflow
    By rmweaver81 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2013, 01:15 PM
  3. Total hours and paid hours calculation advice
    By lozzauk in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-27-2013, 08:25 AM
  4. DateAdd problem
    By si666 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2011, 06:58 AM
  5. DateAdd
    By johnboy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2006, 06:10 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