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 Feb 20th, 2002, 02:09 PM   #1
wjoyner
New Member
 
Join Date: Feb 2002
Location: Wayne Joyner - Omaha, NE
Posts: 9
Default

I know I posted this earlier this week, but received only one response which didn't provide me a answer I can put to use right away. I would really like to find a way of doing this automatically.

I would like to set a range of cells to a particular color based on the day of the week. For example: Monday would be blue, Tuesday, yellow, etc. Additionally, I would for the worksheet to figure our what day of the week it is based on a 02/18/02 date entry format. So today for example, it being - 02/18/02 (Monday) would set cells A1:A5 to a Light Blue background with black font. This is probably easy for some of you, but doing this manually is a real pain. I appreciate any help you can offer. Thanks! Nice Board!
wjoyner is offline   Reply With Quote
Old Feb 20th, 2002, 02:34 PM   #2
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

Could you provide a little more info on how your sheet is layed out? Do you have the dates on the sheet?
Steve Hartman is offline   Reply With Quote
Old Feb 20th, 2002, 02:48 PM   #3
wjoyner
New Member
 
Join Date: Feb 2002
Location: Wayne Joyner - Omaha, NE
Posts: 9
Default

Sheet Format is as follows:

Date Ticket Number Category Issue _ Person Status

02/18/02 567891 ANDS Database won't start Terry Open
02/18/02 567922 Codetables Files Missing Terry Closed
wjoyner is offline   Reply With Quote
Old Feb 20th, 2002, 02:55 PM   #4
wjoyner
New Member
 
Join Date: Feb 2002
Location: Wayne Joyner - Omaha, NE
Posts: 9
Default

Thank you very much. This is just what I was looking for. You all are great! I hope I can contribute to this board some day with the same expertice.
wjoyner is offline   Reply With Quote
Old Feb 20th, 2002, 02:56 PM   #5
DRJ
MrExcel MVP
 
DRJ's Avatar
 
Join Date: Feb 2002
Location: California
Posts: 3,857
Default

An easy way would be to use conditional formatting, however you would only get three different formats. To do more you will have to use VBA.

As for having excel figure out the day from a date format the cell as custom (DDDD) then put in the date and excel will display the day.

For coloring the cells try soomething like this.

Sub Workbook_Open

Dim MyRange as Range

MyRange =The range you want to color based on the day

select case application.worksheetfunction.text(date(),"DDDD")

case "Sunday"

range(myrange).interior.colorindex = 3
'Or
range(myrange).interior.color = "Red"

'Do this for each case based on the settings you want for that day.

case "Monday"

case "Tuesday"

case "Wednesday"

case "Thursday"

case "Friday"

case "Saturday"

end select

end sub

HTH

DRJ
DRJ is offline   Reply With Quote
Old Feb 21st, 2002, 08:42 AM   #6
wjoyner
New Member
 
Join Date: Feb 2002
Location: Wayne Joyner - Omaha, NE
Posts: 9
Default

I'm sorry, but the answer given I have tried with no success. I understand what the worksheet function is doing and that does work. However; making range color changes does not. I guess I am having a hard time understanding how to make the function look at each cell in the date column for the day of the week. Selecting the case based on the value in the date field makes sense, but the range is causing a "SUBSCRIPT Out Of Range error".
wjoyner is offline   Reply With Quote
Old Feb 22nd, 2002, 09:18 AM   #7
wjoyner
New Member
 
Join Date: Feb 2002
Location: Wayne Joyner - Omaha, NE
Posts: 9
Default

I know this is a long post, but this listing colors the range based on day of the week and places grid aound only those cells. Works pretty slick. Sorry it took me so long to figure it out. I appreciate everyone's help. I ended up doing it a different way, so you may want to read through this and make some suggestions for improvement. Please and thanks.

Private Sub Workbook_Open()

For RowCount = 1 To 100

' Color Background of Cells based on Day of the Week

If Range("A1").Offset(RowCount - 1, 0).Text = "Sunday" Then
Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Cells.Interior.ColorIndex = 3

' Place blocks around active cells in table

Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
' With Selection.Borders(xlInsideHorizontal)
' .LineStyle = xlContinuous
' .Weight = xlThin
' .ColorIndex = xlAutomatic
' End With
End If

If Range("A1").Offset(RowCount - 1, 0).Text = "Monday" Then
Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Cells.Interior.ColorIndex = 28

' Place blocks around active cells in table

Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
' With Selection.Borders(xlInsideHorizontal)
' .LineStyle = xlContinuous
' .Weight = xlThin
' .ColorIndex = xlAutomatic
' End With
End If

If Range("A1").Offset(RowCount - 1, 0).Text = "Tuesday" Then
Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Cells.Interior.ColorIndex = 44

' Place blocks around active cells in table

Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
' With Selection.Borders(xlInsideHorizontal)
' .LineStyle = xlContinuous
' .Weight = xlThin
' .ColorIndex = xlAutomatic
' End With
End If

If Range("A1").Offset(RowCount - 1, 0).Text = "Wednesday" Then
Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Cells.Interior.ColorIndex = 4

' Place blocks around active cells in table

Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
' With Selection.Borders(xlInsideHorizontal)
' .LineStyle = xlContinuous
' .Weight = xlThin
' .ColorIndex = xlAutomatic
' End With
End If

If Range("A1").Offset(RowCount - 1, 0).Text = "Thursday" Then
Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Cells.Interior.ColorIndex = 17

' Place blocks around active cells in table

Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
' With Selection.Borders(xlInsideHorizontal)
' .LineStyle = xlContinuous
' .Weight = xlThin
' .ColorIndex = xlAutomatic
' End With
End If

If Range("A1").Offset(RowCount - 1, 0).Text = "Friday" Then
Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Cells.Interior.ColorIndex = 6

' Place blocks around active cells in table

Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
' With Selection.Borders(xlInsideHorizontal)
' .LineStyle = xlContinuous
' .Weight = xlThin
' .ColorIndex = xlAutomatic
' End With
End If

If Range("A1").Offset(RowCount - 1, 0).Text = "Saturday" Then
Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Cells.Interior.ColorIndex = 3

' Place blocks around active cells in table

Range("A1").Offset(RowCount - 1, 0).Activate
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
' With Selection.Borders(xlInsideHorizontal)
' .LineStyle = xlContinuous
' .Weight = xlThin
' .ColorIndex = xlAutomatic
' End With
End If

Next RowCount

End Sub
wjoyner 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:55 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