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 Mar 29th, 2002, 03:09 AM   #1
swaink
Board Regular
 
Join Date: Feb 2002
Location: South UK
Posts: 344
Default

Hi

I have data that includes two Date cols and Two time cols these being date/time of arrival and Date/Time of Departure.

The data has been imported and occasionally the depart time is showing that the departure time is before the arrival time which cant be.

I have been trying to write a macro that checks each entry to see if the departure time is less than the arrival and if so change the field colour.

My problem is this, if an arrival time is say 23:30 hrs and the departure is 01:00 hrs the following morning it gets coloured when it should'nt be.

Can anyone advise how I may get around this problem.

King regards

Kevin

[ This Message was edited by: swaink on 2002-03-29 02:10 ]
swaink is offline   Reply With Quote
Old Mar 29th, 2002, 03:23 AM   #2
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

I have data that includes two Date cols and Two time cols these being date/time of arrival and Date/Time of Departure.

Care to tell the exact range that houses your data?

Aladin Akyurek is offline   Reply With Quote
Old Mar 29th, 2002, 07:48 AM   #3
swaink
Board Regular
 
Join Date: Feb 2002
Location: South UK
Posts: 344
Default

Hi there

The dates are a max of two days ie over one night but the times can be any time during a 24 hour period

Kevin
swaink is offline   Reply With Quote
Old Mar 29th, 2002, 08:27 AM   #4
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-03-29 06:48, swaink wrote:
Hi there

The dates are a max of two days ie over one night but the times can be any time during a 24 hour period

Kevin
Kevin,

That's fine. Now the range that holds your data: Is it A2:D100, or what?

Aladin
Aladin Akyurek is offline   Reply With Quote
Old Mar 29th, 2002, 09:06 AM   #5
Dave Patton
Board Regular
 
Join Date: Feb 2002
Location: Calgary, Alberta Canada
Posts: 2,065
Default

Date1 Date2 Time1 Time2

20/03/2002 20/03/2002 13:00 16:00 TRUE
20/03/2002 21/03/2002 23:30 1:00 TRUE

Formula =AND(D4>=C4,F4-E4+(D4>C4)>0)

Questions:
1. Could you edit or reword the line of your original question. "My problem is this, if an arrival time is say 23:30 hrs and the departure is 01:00 hrs the following morning it gets coloured when it should'nt be."

2. Could you show the macro that you are testing?



[ This Message was edited by: Dave Patton on 2002-03-29 09:11 ]
Dave Patton is offline   Reply With Quote
Old Mar 29th, 2002, 12:05 PM   #6
swaink
Board Regular
 
Join Date: Feb 2002
Location: South UK
Posts: 344
Default

Aladin the date of arr is J2:J1783 and the time is K2:K1783. The Departure date is P2:P1783 with the Time in Q2:Q1783.

Dave im trying to use the macro below to extract the rows that contains the error and paste them to another worksheet.

Sub Checktimes()
Application.ScreenUpdating = False
Range("A2").Select
Do Until ActiveCell = ""

If ActiveCell.Offset(0, 16) > ActiveCell.Offset(0, 10) Then
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Select
Selection.Copy
Sheets("Fault Extract").Select
Range("a1").End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Sheets("System Extract").Select
ActiveCell.Select
ActiveCell.Offset(1, 0).Select

End If
Loop
End Sub
Ps im using col A to work from as it is the only col that contains data in every row.

[ This Message was edited by: swaink on 2002-03-29 11:06 ]

[ This Message was edited by: swaink on 2002-03-29 11:08 ]
swaink is offline   Reply With Quote
Old Mar 29th, 2002, 12:21 PM   #7
Dave Patton
Board Regular
 
Join Date: Feb 2002
Location: Calgary, Alberta Canada
Posts: 2,065
Default


You could revise the references as necessary
and try the formula.

Filter on False and then copy that information.

Once you know that the process works, you could automate it.
Dave Patton is offline   Reply With Quote
Old Mar 31st, 2002, 08:53 AM   #8
swaink
Board Regular
 
Join Date: Feb 2002
Location: South UK
Posts: 344
Default

Dave,

Many thanks I have added the formula and it works great

Thanks again

Kev

swaink 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 04:28 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