Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default VB code for autofill

This will be easy for a VB coder: I have a row range E1:DV1 with concurrent
dates starting Aug 2010 to Nov 2010. I want the rows (lets say 20) below
weekends to be autofilled (Result: Weekends will be visible as columns)
without being affected by subsequent conditional formatting or VB code. The
subsequent code or conditional formatting must autofill between date ranges
obtained from corresponding cells in columns C&D.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default VB code for autofill

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default VB code for autofill

Do you mean that you do not want to see the dates; just the fill color?

If above assumption is correct then don't use my previous suggestion and
apply conditional format as follows.

Select the entire range to be conditionally formatted. (E2:DV? where ? is
max row.)
Select conditional format.
Select formula.
Enter the following formula for week days fill.
=AND(E$1=$C2,E$1<=$D2,WEEKDAY(E$1,2)<6)
Click Format button and set fill color.
Add a rule.
Enter the following formula for weekend fill.
=WEEKDAY(E$1,2)5
Click Format button and set fill color.

Above should work irrespective of whether you use my previous suggestion to
display the dates or if you don't want the dates displayed and you just want
to see the colors.

Don't know if you are aware of this but a tip for entering Conditional
Format. Select the entire range to be formatted and enter the formula as if
you are formatting the first cell in the range only. However, you do have to
think about what addresses need to have absolute addressing (with the $
signs) if the formula is to apply to the rest of the selection. Excel then
automatically applies the Conditional Format to the entire selected range

--
Regards,

OssieMac


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofill data based on an assigned code/prefix anrcreations Excel Worksheet Functions 2 February 11th 10 07:50 PM
How to Autofill HTML code into Excell spreadsheet Lisa Excel Programming 3 June 28th 07 08:03 PM
Autofill cells in 1 column :code ?? Luc Excel Programming 2 February 26th 07 10:33 PM
AutoFill Formula with code Desert Piranha[_46_] Excel Programming 11 February 7th 06 05:46 AM
VBA code to Autofill one cell to many rows below where row count will change TrainingGoddess Excel Programming 5 March 28th 05 03:53 AM


All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"