ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB code for column fill matching weekends (https://www.excelbanter.com/excel-programming/428530-vbulletin-code-column-fill-matching-weekends.html)

Kobus

VB code for column fill matching weekends
 
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)

Wouter HM

VB code for column fill matching weekends
 
On 15 mei, 12:24, Kobus wrote:
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)


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

Kobus

VB code for column fill matching weekends
 
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.

"Kobus" wrote:

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)


Kobus

VB code for column fill matching weekends
 
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.

"Wouter HM" wrote:

On 15 mei, 12:24, Kobus wrote:
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)


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



All times are GMT +1. The time now is 12:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com