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 May 13th, 2002, 02:09 PM   #1
DaK
New Member
 
Join Date: Apr 2002
Posts: 16
Default

Okay, here is the situation. I have code that looks at dates. Depending on the current date, a certain procedure is run.

The vba code looks at a named range called "date" that contains a week in it (ex. range "date" might have something like "5/13 - 5/19" that represents a weeks time)

Now, the range "date" gets its info by beeing linked to another cell. The cell it is linked to is a vlookup that looks at the current date and compares it to a list of dates to determine what week the current date belongs too. (ex. today is 5/13 so it would return that 5/13 belongs to the week "5/13 - 5/19, thus the range "date" would display "5/13 - 5/19"). Have I lost anyone yet???

Now, the cell with the vlookup knows what date to display by looking at another cell that counts "True" statements(get to this in a minute). For expample, if the cell counting true statements value was 20, the vlookup would look at 20 (which is the 20th week of this year) and know to display 5/13 - 5/19.

Now for the True statements, this is where things are getting messed up. The formlua read like this:
=IF($J$70>L70,TRUE,FALSE)
This formula works great except that if the current date falls on the beginning of the week if displays a false instead of true. (ex. today is Monday 5/13, the begining of the week is 5/13 so they are equal and not greater than, this cause the cell that counts true statements to be one short.)

So, what have I done so far.....
I have change the formula to have >= instead of just >. I have reversed everything so that it counts falses instead of true to display the correct date. I have tried adding +1 to the end of the formula so that is adds the extra to the cell that counts true statements.

The problem is, when I change the formula to any of the above ways that I mentioned, the vba code no longer works for some reason. Let me post the vba code for you to look at:

If Range("date") = "1/1 - 1/6" Then
do1
ElseIf Range("date") = "1/7 - 1/13" Then
do2
ElseIf Range("date") = "1/14 - 1/20" Then
do3
ElseIf Range("date") = "1/21 - 1/27" Then
do4
ElseIf Range("date") = "1/28 - 2/3" Then
do5
ElseIf Range("date") = "2/4 - 2/10" Then
do6
ElseIf Range("date") = "2/11 - 2/17" Then
do7
ElseIf Range("date") = "2/18 - 2/24" Then
do8
ElseIf Range("date") = "2/25 - 3/3" Then
do9
ElseIf Range("date") = "3/4 - 3/10" Then
do10
ElseIf Range("date") = "3/11 - 3/17" Then
do11
ElseIf Range("date") = "3/18 - 3/24" Then
do12
ElseIf Range("date") = "3/25 - 3/31" Then
do13
ElseIf Range("date") = "4/1 - 4/7" Then
do14
ElseIf Range("date") = "4/8 - 4/14" Then
do15
ElseIf Range("date") = "4/15 - 4/21" Then
do16
ElseIf Range("date") = "4/22 - 4/28" Then
do17
ElseIf Range("date") = "4/29 - 5/5" Then
do18
ElseIf Range("date") = "5/6 - 5/12" Then
do19
ElseIf Range("date") = "5/13 - 15/19" Then
do20
ElseIf Range("date") = "5/20 - 5/26" Then
do21
ElseIf Range("date") = "5/27 - 6/2" Then
do22
ElseIf Range("date") = "6/3 - 6/9" Then
do23
ElseIf Range("date") = "6/10 - 6/16" Then
do24
ElseIf Range("date") = "6/17 - 6/23" Then
do25
ElseIf Range("date") = "6/24 - 6/30" Then
do26
ElseIf Range("date") = "7/1 - 7/7" Then
do27
ElseIf Range("date") = "7/8 - 7/14" Then
do28
ElseIf Range("date") = "7/15 - 7/21" Then
do29
ElseIf Range("date") = "7/22 - 7/28" Then
do30
ElseIf Range("date") = "7/29 - 8/4" Then
do31
ElseIf Range("date") = "8/5 - 8/11" Then
do32
ElseIf Range("date") = "8/12 - 8/18" Then
do33
ElseIf Range("date") = "8/19 - 8/25" Then
do34
ElseIf Range("date") = "8/26 - 9/1" Then
do35
ElseIf Range("date") = "9/2 - 9/8" Then
do36
ElseIf Range("date") = "9/9 - 9/15" Then
do37
ElseIf Range("date") = "9/16 - 9/22" Then
do38
ElseIf Range("date") = "9/23 - 9/29" Then
do39
ElseIf Range("date") = "9/30 - 10/6" Then
do40
ElseIf Range("date") = "10/7 - 10/13" Then
do41
ElseIf Range("date") = "10/14 - 10/20" Then
do42
ElseIf Range("date") = "10/21 - 10/27" Then
do43
ElseIf Range("date") = "10/28 - 11/3" Then
do44
ElseIf Range("date") = "11/4 - 11/10" Then
do45
ElseIf Range("date") = "11/11 - 11/17" Then
do46
ElseIf Range("date") = "11/18 - 11/24" Then
do47
ElseIf Range("date") = "11/25 - 12/1" Then
do48
ElseIf Range("date") = "12/2 - 12/8" Then
do49
ElseIf Range("date") = "12/9 - 12/15" Then
do50
ElseIf Range("date") = "12/16 - 12/22" Then
do51
ElseIf Range("date") = "12/23 - 12/29" Then
do52
ElseIf Range("date") = "12/30 - 12/31" Then
do53
End If

End Sub

And when I jump into the code (f8) I hover the mouse over Range("date") which will say that is equals 5/13 - 5/19 but when it gets to the if statement for it, it just keeps on going like the 2 don't match each other. Yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah.... Can someone explain why it works one way and not the others. They all make the date appear correctly in the "date" range that the vba code needs, why oh why does it not work.

Any explainaition would be greatly appreciated. Also, I know that I could just change the week dates to start with sunday but that would be too easy.

TIA DaK
DaK is offline   Reply With Quote
Old May 13th, 2002, 03:54 PM   #2
DaK
New Member
 
Join Date: Apr 2002
Posts: 16
Default

Actually, it seems any changes I make to the cells results in the code not working.
If I change the formulas, I change the dates, I insert or delete rows.... Any slight change I make to any cells make the code not work???? What is going on???
I was going to do the sunday thing I mentioned before but when I change the 5/13 to a 5/12, the code didnt' work!!!

AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

Thank you for your patience.

DaK
DaK is offline   Reply With Quote
Old May 13th, 2002, 04:01 PM   #3
Asala42
Board Regular
 
Join Date: Feb 2002
Location: Southfield,MI USA
Posts: 1,030
Default

G'day,

If you want to send me your file I'll take a stab.

asala42@yahoo.com

Adam
Asala42 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 12:57 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