Hi,
I have this problem. If I input two dates, for example, 8/1/04 and 8/23/04
is there any function that outputs (prints) all the dates in between, inclusively? So, 8/1/04 8/02/04 ... 8/22/04 8/23/04 ?
Any help is appreciated! Thanks!
Kim
Hi,
I have this problem. If I input two dates, for example, 8/1/04 and 8/23/04
is there any function that outputs (prints) all the dates in between, inclusively? So, 8/1/04 8/02/04 ... 8/22/04 8/23/04 ?
Any help is appreciated! Thanks!
Kim
In a bit of a hurry, but here's the code from a userform I developed a while ago so that people at my company could add a range of dates at once to a daily Database of Interest Rates
Option Explicit
'All code by Will Riley - December 2003
'*****************************************************
'* This is the userform code for adding new rates to *
'* the Rates database - includes error checking for *
'* valid dates & rates *
'*****************************************************
Private Sub CmdbtnAddRates_Click()
Dim MyArray()
Dim Rows As Long
Dim i As Long, r As Long
Dim startrow As Long, endrow As Long
Dim rndata As Range
Dim datetofind1 As Date
Dim datetofind2 As Date
Dim var1, var2
'turn off screenupdating
Application.ScreenUpdating = False
'check for a valid date entry in the from_date textbox
If IsDate(TxtFrom.Text) = False Then
MsgBox "This is a date field only."
TxtFrom.Text = ""
Exit Sub
Else
'then we check to see if rates for that date
'have already been added using the MATCH function
Set rndata = Sheet1.Range("A1:A" & Range("A1").End(xlDown).Row)
datetofind1 = TxtFrom.Text
var1 = Application.Match(CLng(datetofind1), rndata, 0)
If Not IsError(var1) Then
MsgBox "Rates for that From Date already Exist"
TxtFrom.Text = ""
Exit Sub
End If
Set rndata = Nothing
End If
'check for a valid date entry in the to_date textbox
If IsDate(TxtTo.Text) = False Then
MsgBox "This is a date field only."
TxtTo.Text = ""
Exit Sub
Else
'then we check to see if rates for that date
'have already been added using the MATCH function
Set rndata = Sheet1.Range("A1:A" & Range("A1").End(xlDown).Row)
datetofind2 = TxtTo.Text
var2 = Application.Match(CLng(datetofind2), rndata, 0)
If Not IsError(var2) Then
MsgBox "Rates for that To Date already Exist"
TxtTo.Text = ""
Exit Sub
End If
Set rndata = Nothing
End If
'checks for no Base Rate entry
If TxtRate.Text = "" Then
MsgBox "Please Enter a Rate."
TxtRate.Text = ""
Exit Sub
End If
'then we set the number of values to add to the database
Rows = (DateValue(TxtTo.Value) - DateValue(TxtFrom.Value) + 1)
If Rows <= 0 Then
MsgBox ("No Data to Enter")
Exit Sub
Else
'fill the VBA array with dates - From to To dates
ReDim MyArray(1 To Rows, 1 To 1)
i = DateValue(TxtFrom.Value)
For r = 1 To Rows
MyArray(r, 1) = i
i = i + 1
Next r
'set the start row to paste the dates & rate values
startrow = Sheets("Data").Range("A65536").End(xlUp).Row + 1
'set the end row for the same
endrow = (startrow + Rows) - 1
'paste the VBA date & Rate array into the range in the data sheet
Sheets("Data").Activate
Range(Cells(startrow, 1), Cells(endrow, 1)) = MyArray
Range(Cells(startrow, 2), Cells(endrow, 2)) = (TxtRate.Value / 100)
Sheets("Base Rates").Activate
'turn on the screen updating
Application.ScreenUpdating = True
'unload the form
Application.Calculate
Unload FMNewRates
End If
Application.Goto Range("BrHome")
End Sub
Display More
I attach the file too.... sure if you don't get it somweone else here will explain what I was up to
ThankS!!! The codes are much more than I need, but it's great help!!
Don’t have an account yet? Register yourself now and be a part of our community!