Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default VBA to populate workdat between dates

Hello,

I am hoping someone can help me. The problem is I am trying to get a VBA
code that will request the user to input two dates and will populate the
workdays between these dates into a specified column

User Inputs

StartDate = 01-Mar-2006
EndDate = 01-Mar-2007

Output in say column C
01-Mar-2006
02-Mar-2006
03-Mar-2006
06-Mar-2006
07-Mar-2006
08-Mar-2006
09-Mar-2006
10-Mar-2006
13-Mar-2006
14-Mar-2006
15-Mar-2006

etc

Thanks in Advance


  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 3,355
Default VBA to populate workdat between dates

This will give you M-F without holidays.

Sub betweenDates()
Dim StartDate As Date
Dim EndDate As Date
Dim CurDate As Date
Dim aWS As Worksheet

Set aWS = ActiveSheet

StartDate = InputBox("Enter Start Date: ", Start)
EndDate = InputBox("Enter End Date: ", Last)

CurDate = StartDate
lrow = 1

aWS.Cells(lrow, 1).Value = "Start Date: " & Format(StartDate, "mm/dd/yyyy")
lrow = lrow + 1
aWS.Cells(lrow, 1).Value = "End Date: " & Format(EndDate, "mm/dd/yyyy")

lrow = lrow + 2
Do While CurDate = StartDate And CurDate <= EndDate
aWS.Cells(lrow, 1).Value = Format(CurDate, "mm/dd/yyyy")
Debug.Print Weekday(CurDate, vbSunday)

If Weekday(CurDate, vbSunday) = 5 Then
CurDate = CurDate + 3
Else
CurDate = CurDate + 1
End If
lrow = lrow + 1

Loop


End Sub

HTH,
Barb Reinhardt

"fLiPMoDĀ£" wrote:

Hello,

I am hoping someone can help me. The problem is I am trying to get a VBA
code that will request the user to input two dates and will populate the
workdays between these dates into a specified column

User Inputs

StartDate = 01-Mar-2006
EndDate = 01-Mar-2007

Output in say column C
01-Mar-2006
02-Mar-2006
03-Mar-2006
06-Mar-2006
07-Mar-2006
08-Mar-2006
09-Mar-2006
10-Mar-2006
13-Mar-2006
14-Mar-2006
15-Mar-2006

etc

Thanks in Advance



  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 14
Default VBA to populate workdat between dates

Hello Barb,

Fantastic! works like a gem!

Thanks again!

"Barb Reinhardt" wrote in message
...
This will give you M-F without holidays.

Sub betweenDates()
Dim StartDate As Date
Dim EndDate As Date
Dim CurDate As Date
Dim aWS As Worksheet

Set aWS = ActiveSheet

StartDate = InputBox("Enter Start Date: ", Start)
EndDate = InputBox("Enter End Date: ", Last)

CurDate = StartDate
lrow = 1

aWS.Cells(lrow, 1).Value = "Start Date: " & Format(StartDate,

"mm/dd/yyyy")
lrow = lrow + 1
aWS.Cells(lrow, 1).Value = "End Date: " & Format(EndDate, "mm/dd/yyyy")

lrow = lrow + 2
Do While CurDate = StartDate And CurDate <= EndDate
aWS.Cells(lrow, 1).Value = Format(CurDate, "mm/dd/yyyy")
Debug.Print Weekday(CurDate, vbSunday)

If Weekday(CurDate, vbSunday) = 5 Then
CurDate = CurDate + 3
Else
CurDate = CurDate + 1
End If
lrow = lrow + 1

Loop


End Sub

HTH,
Barb Reinhardt

"fLiPMoD£" wrote:

Hello,

I am hoping someone can help me. The problem is I am trying to get a VBA
code that will request the user to input two dates and will populate the
workdays between these dates into a specified column

User Inputs

StartDate = 01-Mar-2006
EndDate = 01-Mar-2007

Output in say column C
01-Mar-2006
02-Mar-2006
03-Mar-2006
06-Mar-2006
07-Mar-2006
08-Mar-2006
09-Mar-2006
10-Mar-2006
13-Mar-2006
14-Mar-2006
15-Mar-2006

etc

Thanks in Advance





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
Populate a form Doug Excel Worksheet Functions 3 December 15th 06 03:33 PM
make dates automatically populate a cell on different worksheets Meenie Excel Worksheet Functions 2 December 1st 06 09:46 PM
Auto populate dates waiter11 Excel Discussion (Misc queries) 2 May 28th 06 09:50 AM
Cells populate on specific dates JD MPLS Excel Worksheet Functions 1 February 9th 06 03:12 PM
Populate List Box John in Surrey Excel Worksheet Functions 0 October 26th 05 11:25 AM


All times are GMT +1. The time now is 08:39 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"