VB code for column fill matching weekends

  • Thread starter Thread starter Kobus
  • Start date Start date
K

Kobus

This will be easy for a VB coder: I have a row with calender dates across
about 100 days (cells E:DV). I want the colums representing weekends to be
autofilled and remain unaffected by subsequent conditional formatting (or vb
code). Then (this is the subsequent part) rows below must be filled between
date ranges obtained from cells from columns, say C and D. Columns C being a
start date and D an end date. Note I have used the WORKDAY FUNCTION to
identify weekends through numbers 1 - 7, if that would help)
 
This will be easy for a VB coder: I have a row with calender dates across
about 100 days (cells E:DV).  I want the colums representing weekends to be
autofilled and remain unaffected by subsequent conditional formatting (orvb
code). Then (this is the subsequent part) rows below must be filled between
date ranges obtained from cells from columns, say C and D.  Columns C being a
start date and D an end date. Note I have used the WORKDAY FUNCTION to
identify weekends through numbers 1 - 7, if that would help)

Hi Kobus,

Assuming you have the startdate in cell C2 and the enddate in cell D2

You can solve this with conditional formatting only.
For marking the weekends use the WEEKDAY function
=WEEKDAY(E$1,2)>5
For marking the days from your startdate unto and including the
enddate add a second rule and use
=AND(E$1>=$C$2,E$1<=$D$2)
Use the brush to copy these conditiond from column E to the right.


HTH,

Wouter
 
As you may have noticed I posted the same question twice (search Kobus and it
will pick it up). I think the AND should be OR. Something is not working
yet, but thanks for sending me on the path. I thought VB would have been the
answer as it may be more forgiving in adding and deleting columns.
 
THE ERROR WAS WITH A DOLLAR SIGN
THANKS IT WORKS GREAT!!
For marking the weekends use the WEEKDAY function
=WEEKDAY(E$1,2)>5
For marking the days from your startdate unto and including the
enddate add a second rule and use
=AND(E$1>=$C2,E$1<=$D2)
Use the brush to copy these conditiond from column E to the right.
 
Back
Top