Excel/Excel formatting


i have a spreadsheet i use monthly and was wondering if there is a way to get the weekend dates to grey out so as i enter the information into the sheet i don't enter anything into these cells in error. the date is in column A and i have information through AD.

Thank you.

Hi Harold,

I assumed you want the entire row, not just the date cell, to be greyed out. The are two ways to accomplish this: via conditional formatting, and via macro.  I chose the macro approach because putting conditional formatting in all the cells would add quite a bit of overhead to your workbook, and possibly interfere with other conditional formatting you might have.  So here is a simple macro that will do it:

Sub GreyWeekends()
  'greys out all rows of the active worksheet that have weekend dates in column A
  Dim iRow       As Long
  For iRow = 1 To Range("A65536").End(xlUp).Row
     If IsDate(Cells(iRow, "A")) Then
        If Weekday(Cells(iRow, "A"), vbMonday) > 5 Then Rows(iRow).Interior.ColorIndex = 15
     End If
  Next iRow
End Sub

To install this in your workbook go to the Visual Basic Editor (keyboard Alt-TMV), insert a new macro module (Alt-IM) and paste this code into the code pane.  To run the macro go back to Excel and Alt-F8, select the macro and click Run.

Keep Excelling.

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Damon Ostrander


I have extensive experience with VBA programming in Excel 5 through Excel 2013. As a former aerospace engineer with a large aerospace corporation and consultant in a small defense technology services company, I have developed a wide range of applications in VBA, including simulations involving mixed-language programming, satellite orbit mechanics, graphics and animation, and real-time applications. I am interested in moderate to hard VBA-related questions only.


I have developed and taught several courses in Excel VBA programming and also VBA programming in Office 97, 2000, and 2007. I have developed a number of large technical applications in Excel VBA for use within the aerospace industry.

B.S. in Electrical Engineering and Computer Science, University of California, Berkeley.

©2016 About.com. All rights reserved.