Hi All,
I am a newbie to VBA programming and I am very much interested to correct my mistakes
However, I am unable to solve a problem that involves calculation of Weekdays and storing them in an array
Excel Version: 2007
Problem :
Column A Column B Column C
16-May-13
19-May-13
In the above example , user inputs two dates which can e defined as Start Dates and End Dates(Lets Say 16th May,2013 is the Start Date and 19st May is end Date). Now what i need is that I should be able to create an array that would store details of all the days and dates for all the days between the above dates.
Note: I need this job to be done through Macro instead of to be done via Excel Formulae
Sample Output:
<tbody>
</tbody>
Sub Dates()
Dim DateArray() As Variant
Dim SDate As Date
Dim EDate As Date
Dim D As Integer
Dim IsDate As Date
SDate = InputBox("Please Input the StartDate")
Sheet1.Range(A1).Value = SDate
EDate = InputBox("Please Enter the EndDate")
Sheet1.Range(A2).Value = EDate
D = (EDate - SDate) + 1
ReDim DateArray(1 To D, 2)
For i = 1 To D
DateArray(i, 1) = SDate
DateArray(i, 2) = Day(DateArray(i, 1))
SDate = SDate + 1
Next
End Sub
Help Needed on :
1. How do i calculate the day of each of these dates ?
2. How do i print this array to one of the columns ?
Many Thanks !
I am a newbie to VBA programming and I am very much interested to correct my mistakes
However, I am unable to solve a problem that involves calculation of Weekdays and storing them in an array
Excel Version: 2007
Problem :
Column A Column B Column C
16-May-13
19-May-13
In the above example , user inputs two dates which can e defined as Start Dates and End Dates(Lets Say 16th May,2013 is the Start Date and 19st May is end Date). Now what i need is that I should be able to create an array that would store details of all the days and dates for all the days between the above dates.
Note: I need this job to be done through Macro instead of to be done via Excel Formulae
Sample Output:
16 May-13 | 16-May-13 | Thursday |
19 May-13 | 17-may-13 | Friday |
18-May-13 | Saturday | |
19-May-13 | Sunday |
<tbody>
</tbody>
Sub Dates()
Dim DateArray() As Variant
Dim SDate As Date
Dim EDate As Date
Dim D As Integer
Dim IsDate As Date
SDate = InputBox("Please Input the StartDate")
Sheet1.Range(A1).Value = SDate
EDate = InputBox("Please Enter the EndDate")
Sheet1.Range(A2).Value = EDate
D = (EDate - SDate) + 1
ReDim DateArray(1 To D, 2)
For i = 1 To D
DateArray(i, 1) = SDate
DateArray(i, 2) = Day(DateArray(i, 1))
SDate = SDate + 1
Next
End Sub
Help Needed on :
1. How do i calculate the day of each of these dates ?
2. How do i print this array to one of the columns ?
Many Thanks !