MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 4th, 2002, 06:21 AM   #1
wallaceka
New Member
 
Join Date: Apr 2002
Posts: 11
Default

I have a user that would like to track the time that elapses between the time he attempts to initiate contact with someone and the time they get back to him. Ideally, if this could be tracked down to the minute, that would be grand. The span could potentially be days or hours (worst case weeks). I know this is POSSIBLE; I am just not sure how to implement it. I have posted several times to this board, always with amazing results. Thanks for any help given, Kathi.
wallaceka is offline   Reply With Quote
Old Apr 4th, 2002, 07:50 AM   #2
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Hi
Just for clarity...
Two times in two columns? Right?
Tom
Tom Schreiner is offline   Reply With Quote
Old Apr 4th, 2002, 07:55 AM   #3
wallaceka
New Member
 
Join Date: Apr 2002
Posts: 11
Default

I am not sure the user cares about presentation, just a start time column, an end time column, and I would suppose a third with a formula to calculate the time elapsed. Does that make sense? *ponder*
wallaceka is offline   Reply With Quote
Old Apr 4th, 2002, 08:43 AM   #4
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Hi
I coulc not figure out a formula that took less than a page so I cheated with VBA code.
Paste this in your sheet module.

A double-click on column A or B inserts the current date and time.
When double-clicking on B, C is filled with a result such as "5 days. 1 hrs. 20 min."
If there is already a time entered, a double-click will not change it.
If one of these times is manually edited, just double-click on column B to update the results in C
Try it out
Tom

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim dStart As Date
Dim dEnd As Date
If Target.Column = 1 And Not IsDate(Target) Then _
Target = Date & " " & Time
If Target.Column = 2 Then
If Not IsDate(Target) Then Target = Date & " " & Time
If IsDate(Target.Offset(0, -1).Value) Then
dStart = Target.Offset(0, -1).Value
dEnd = Target.Value
Target.Offset(0, 1).Value = _
DateDiff("d", dStart, dEnd) & " days. " & _
DateDiff("h", dStart, dEnd) - (DateDiff("d", dStart, dEnd) * 24) & " hrs. " & _
DateDiff("n", dStart, dEnd) - (DateDiff("h", dStart, dEnd) * 60) & " min. "
End If
End If
End Sub

[ This Message was edited by: TsTom on 2002-04-04 07:45 ]
Tom Schreiner is offline   Reply With Quote
Old Apr 4th, 2002, 08:59 AM   #5
wallaceka
New Member
 
Join Date: Apr 2002
Posts: 11
Default

man, I feel like such a noodle. I have never used the vba aspect of excel successfully. I tried fudging around with it once or twice and I have all these old modules I cannot figure out how to get rid of. Can you suggest a really good book on vba with excel formulas type of thing?
wallaceka is offline   Reply With Quote
Old Apr 4th, 2002, 09:03 AM   #6
Yogi Anand
MrExcel MVP
 
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
Default

Quote:
On 2002-04-04 05:21, wallaceka wrote:
I have a user that would like to track the time that elapses between the time he attempts to initiate contact with someone and the time they get back to him. Ideally, if this could be tracked down to the minute, that would be grand. The span could potentially be days or hours (worst case weeks). I know this is POSSIBLE; I am just not sure how to implement it. I have posted several times to this board, always with amazing results. Thanks for any help given, Kathi.
Hi ponder:
Tom has given a VBA solution -- here is a formula -- I have not tested it for correctness, but try it:

in cell A2 3/28/02 10:05
in cell B2 4/4/02 11:07

in cell C2
=INT(B2-A2)& "days, "&INT(MOD(B2-a2,1)*24)&" hours, "&INT(MOD((B2-A2)*24,1)*60)&" minutes"

with the result as

7days, 1 hours, 1 minutes


Please post back if it works for you ... otherwise explain a little further and let us take it from there!


_________________
Yogi Anand

Edit: Deleted inactive website from hardcoded signature

[ This Message was edited by: Yogi Anand on 2003-01-19 14:10 ]
Yogi Anand is offline   Reply With Quote
Old Apr 4th, 2002, 09:19 AM   #7
wallaceka
New Member
 
Join Date: Apr 2002
Posts: 11
Default

Yogi-
Thanks for the reply. The answer I received after testing was 0days, 0 hours, 0 minutes. I copied and pasted the formula to make sure I got it all.
Kathi
wallaceka is offline   Reply With Quote
Old Apr 4th, 2002, 09:37 AM   #8
wallaceka
New Member
 
Join Date: Apr 2002
Posts: 11
Default

*blushing.bright.red*
I am sooooo dumb.
It works and wonderfully!! You guys are the greatest.
I hesitate to tell you that I pasted it into the wrong cell for testing purposes.

A million thanks!
Kathi
wallaceka is offline   Reply With Quote
Old Apr 4th, 2002, 09:53 AM   #9
Dave Patton
Board Regular
 
Join Date: Feb 2002
Location: Calgary, Alberta Canada
Posts: 2,065
Default



=B2-A2

Format custom d h:mm

Dave Patton is offline   Reply With Quote
Old Apr 4th, 2002, 09:57 AM   #10
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Now I'm blushing as Dave smiles at my very easy, short solution...
It's the thought/effort that counts! Right?
Tom Schreiner is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 07:18 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes