How to generate a list with the date of every other Friday.

TheThird152

New Member
Joined
May 29, 2009
Messages
4
Greetings!

I'm brand new to this board and just beginning to learn VBA, so please bear with me. I'm running Windows XP Pro and I use Excel 2003 & 2007, but am using 2003 for this project.

Ok, here's the scenario. At work, I've been asked to redesign a timesheet for our hourly employees. I'm probably overdoing it, but it is a great opportunity for me to learn some VBA. I've got most of my programming done, but I could use some help figuring out something that has to do with a date.

On my timesheet, there is a button that, when clicked, allows you to select a pay period end date. Our pay periods end every other Friday. When the button is clicked, it opens a form I designed that has a listbox that I manually entered every pay period for the year into. Here is the code I used:

Private Sub UserForm_Initialize()
' Populate the ListBox control.
listPayPeriodEndDates.AddItem "04/03/09"
listPayPeriodEndDates.AddItem "04/17/09"
listPayPeriodEndDates.AddItem "05/01/09"
listPayPeriodEndDates.AddItem "05/15/09"
listPayPeriodEndDates.AddItem "05/29/09"
listPayPeriodEndDates.AddItem "06/05/09"
listPayPeriodEndDates.AddItem "06/19/09"
listPayPeriodEndDates.AddItem "07/03/09"
listPayPeriodEndDates.AddItem "07/17/09"
listPayPeriodEndDates.AddItem "07/31/09"
listPayPeriodEndDates.AddItem "08/07/09"
listPayPeriodEndDates.AddItem "08/21/09"
listPayPeriodEndDates.AddItem "09/04/09"
listPayPeriodEndDates.AddItem "09/18/09"
listPayPeriodEndDates.AddItem "10/02/09"
listPayPeriodEndDates.AddItem "10/16/09"
listPayPeriodEndDates.AddItem "10/30/09"
listPayPeriodEndDates.AddItem "11/13/09"
listPayPeriodEndDates.AddItem "11/27/09"
listPayPeriodEndDates.AddItem "12/04/09"
listPayPeriodEndDates.AddItem "12/18/09"
listPayPeriodEndDates.AddItem "01/01/10"
' Select the default value
listPayPeriodEndDates.Value = "04/03/09"
End Sub

What I'd like to do instead is have VBA populate the listbox (or combobox or what have you) dynamically, by using a reference point (say, the first pay period of the year) and then populating every other Friday from that point forward. Also, it would be great if it could reference the current date as to only list pay period end dates in the future (or even the two prior to todays date, and then maybe 3 or 4 pay period end dates in the future).

I'd certainly appreciate any input anyone might have, I'm open to all ideas. Also, it's no big hurry, I'll keep working on it in the meantime.

Thanks in advance for any help! :)

Paul
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,215,054
Messages
6,122,901
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top