Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Find holidays

Hello,
I have a workbook with 26 paysheets, which includes the dates of a given pay
period. I'd like a macro that will find the cells where a holiday occurs.
Christmas was quite easy to do as it anyways appears in the last paysheet.

Veteran's day, however, is more challenging because it can occcur in one of
two pay periods. I'd like a macro that will find that date. When I record
that macro it hardcodes the name of the worksheet. This doesn't work for me
because the worksheet name changes from year to year.

I was invisioning a do while loop that'll search each worksheet for each
holiday.

For instance,
Sub DoWhile()
Do while (condition is true)
Perform task
Loop
End sub

Loop would end when date is found. Is there an IsFound() boolean function
in VBA that would make this happen?

Thanks in advance for your help,
Ellen

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Find holidays

Function GetVeteransDay(lYear As Long) As Date

Dim daDate As Date

daDate = DateSerial(lYear, 11, 11)

Select Case Weekday(daDate, vbMonday)
Case 6
GetVeteransDay = daDate - 1
Case 7
GetVeteransDay = daDate + 1
Case Else
GetVeteransDay = daDate
End Select

End Function


Sub test()

MsgBox Format(GetVeteransDay(2007), "ddd dd/mmm/yyyy")

End Sub


RBS


"EllenM" wrote in message
...
Hello,
I have a workbook with 26 paysheets, which includes the dates of a given
pay
period. I'd like a macro that will find the cells where a holiday occurs.
Christmas was quite easy to do as it anyways appears in the last paysheet.

Veteran's day, however, is more challenging because it can occcur in one
of
two pay periods. I'd like a macro that will find that date. When I
record
that macro it hardcodes the name of the worksheet. This doesn't work for
me
because the worksheet name changes from year to year.

I was invisioning a do while loop that'll search each worksheet for each
holiday.

For instance,
Sub DoWhile()
Do while (condition is true)
Perform task
Loop
End sub

Loop would end when date is found. Is there an IsFound() boolean function
in VBA that would make this happen?

Thanks in advance for your help,
Ellen


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Find holidays

Thanks so much. Your code was very useful!!!

"EllenM" wrote:

Hello,
I have a workbook with 26 paysheets, which includes the dates of a given pay
period. I'd like a macro that will find the cells where a holiday occurs.
Christmas was quite easy to do as it anyways appears in the last paysheet.

Veteran's day, however, is more challenging because it can occcur in one of
two pay periods. I'd like a macro that will find that date. When I record
that macro it hardcodes the name of the worksheet. This doesn't work for me
because the worksheet name changes from year to year.

I was invisioning a do while loop that'll search each worksheet for each
holiday.

For instance,
Sub DoWhile()
Do while (condition is true)
Perform task
Loop
End sub

Loop would end when date is found. Is there an IsFound() boolean function
in VBA that would make this happen?

Thanks in advance for your help,
Ellen

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
How to get Holidays in cell/s? (Find explaination in details) Nilay Excel 2003 Excel Worksheet Functions 3 December 8th 07 06:53 PM
Holidays JB Excel Worksheet Functions 2 January 10th 07 12:27 PM
Holidays edwardpestian Excel Worksheet Functions 2 July 25th 06 04:02 PM
Considering Holidays Nicole Seibert Excel Programming 4 July 3rd 06 01:33 PM
holidays bamboozled Excel Discussion (Misc queries) 4 May 29th 06 04:08 PM


All times are GMT +1. The time now is 08:37 AM.

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"