View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Kobus Kobus is offline
external usenet poster
 
Posts: 22
Default VB code for autofill

I used the wrong term. I need blank cells to be colour filled according to
the criteria. I could use the formula and then apply conditional formatting
afterward with your solution. (I am currently working with the OR function
and think it may also work) The effect should be a bar chart effect

Lets see if I fully understand your question.
You have a row of dates (1st Aug 2010 to 30th Nov 2010) in cells E1:DV1. (YES)
You have a start date in column C (YES)
You have an end date in column D (YES)
You want all weekend dates filled in for all the columns. (IF DATE IN E1 =
WEEKEND THEN COLOUR FILL)
You want the weekday dates filled in for the period between the start and
end. (COLOUR FILLED)


"OssieMac" wrote:

Lets see if I fully understand your question.
You have a row of dates (1st Aug 2010 to 30th Nov 2010) in cells E1:DV1.
You have a start date in column C
You have an end date in column D
You want all weekend dates filled in for all the columns.
You want the weekday dates filled in for the period between the start and end.

If above is correct then it can be done with a fomula without using VBA.

Assume that C2 contains a start date and D2 an end date.
Enter the following formula in E2.

=IF(AND(E$1=$C2,E$1<=$D2,WEEKDAY(E$1,2)<6),E$1,IF (WEEKDAY(E$1,2)5,E$1,""))

Note: Although the formula may appear as 2 lines in the post, it is actually
one line so you will have to fix that up when you copy it into the formular
bar.

You should be able to copy the formula across all columns and down as far as
you want.

Entering or changing values in columns C and D should produce the results
you desire.

Note: If both C and D are blank or only C contains a date, only the weekends
will be populated. If only column D contains a date and C is blank, then all
columns will be populated.

--
Regards,

OssieMac