1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Excel macro time comparison

Discussion in 'Software Development' started by Mzun, Sep 15, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. Mzun

    Mzun Thread Starter

    Joined:
    Jun 29, 2011
    Messages:
    58
    I'm trying to write a macro that calculates the difference between two times. If the difference is greater that 8 hours then the diffence is set equal to 8 hours. My code currently looks like this but it doesn't work (cell A1 stores the difference between the two times).

    If Range("A1").Value > 8 Then
    Range("A1").Value = 8
    End If

    Any Suggestions?
     
  2. andythepandy

    andythepandy

    Joined:
    Jul 2, 2006
    Messages:
    367
  3. meynardo

    meynardo

    Joined:
    Sep 20, 2011
    Messages:
    1
    Did you try:

    =IF(A1>8,8,A1)

    Or give us more details on how your spreadsheet is organized.
     
  4. henry48

    henry48

    Joined:
    Sep 27, 2011
    Messages:
    2
    [FONT=&quot]A macro is a series of commands that perform a specific task in Excel. To save time when performing common operations you can create a macro with the macro recorder that can be run whenever you need to perform the task. This tutorial describes step by step how to create a simple macro in Excel using the macro recorder.[/FONT]
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1017784