Results 1 to 8 of 8

Code That Allows User to Select Two Cells and Get the Difference as an Output

Threaded View

  1. #3
    Registered User
    Join Date
    09-02-2012
    Location
    New Roads, LA
    MS-Off Ver
    Excel 2007\10
    Posts
    22

    Re: Code That Allows User to Select Two Cells and Get the Difference as an Output

    XLAdept

    Thank you for the expedient reply. What I'm really trying to do is build a macro that would subtract the min time from the max time of a User Selection that isn't a specified range until Selected and display the difference in any way but, the thing I can't figure out is how to get minimum and maximum values of a selection called up.
    I fear I'm not doing a very good job of explaining myself.
    The following is the idea of what I'm trying to accomplish but of course my syntax is all wrong and the code does not work. I'm really having trouble wrapping my head around VBA's hierarchy and syntax.

    Sub MinMaxDiff()
        Dim StartTime As Date, StopTime As Date
        Dim Duration As Date
    StartTime = Application.WorksheetFunction.Min(Range("Selection"))
    StopTime = Application.WorksheetFunction.Max(Range("Selection"))
    Duration = StopTime - StartTime
    
    msgbox Duration
    
    End Sub
    Last edited by Cutter; 09-08-2012 at 06:22 AM. Reason: Added code tags

Thread Information

Users Browsing this Thread

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

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