j_bayat194
New Member
- Joined
- Jul 24, 2019
- Messages
- 1
Dear all;
How can I solve this error:
Sincerely.
"Application-defined or object-defined error"
I have two sheets, "SETUP", "RESULTS". Setup contains the information.
Sub Mine()
Dim out() As Double
Dim date_a() As Date
Dim dt As Double
Dim I, start, n, j As Integer
Dim startdate, date_, date1 As Date
Dim rr, dd As String
dt = 1
n = 730
startdate = 1/1/2018
date1 = 1/1/2013
date_ = startdate
start = start_index(startdate, date1)
ReDim out(2 To n - strart + 2, 2 To 20) As Double
ReDim date_a(2 To n - strart + 2, 1 To 1) As Date
j = 1
For I = start To n
date_ = date_ + dt
date_a(j + 1, 1) = date_
Next
dd = "a2:a" & n - start + 2
Sheets("RESULTS").Range(dd).Value = date_a
End Sub
Function start_index(startdate, date1) As Integer
start_index = MAX(DateDiff("d", date1, startdate) + 1, 1)
End Function
Function MAX(a, b)
If a > b Then MAX = a Else MAX = b
End Function
How can I solve this error:
Sincerely.
"Application-defined or object-defined error"
I have two sheets, "SETUP", "RESULTS". Setup contains the information.
Sub Mine()
Dim out() As Double
Dim date_a() As Date
Dim dt As Double
Dim I, start, n, j As Integer
Dim startdate, date_, date1 As Date
Dim rr, dd As String
dt = 1
n = 730
startdate = 1/1/2018
date1 = 1/1/2013
date_ = startdate
start = start_index(startdate, date1)
ReDim out(2 To n - strart + 2, 2 To 20) As Double
ReDim date_a(2 To n - strart + 2, 1 To 1) As Date
j = 1
For I = start To n
date_ = date_ + dt
date_a(j + 1, 1) = date_
Next
dd = "a2:a" & n - start + 2
Sheets("RESULTS").Range(dd).Value = date_a
End Sub
Function start_index(startdate, date1) As Integer
start_index = MAX(DateDiff("d", date1, startdate) + 1, 1)
End Function
Function MAX(a, b)
If a > b Then MAX = a Else MAX = b
End Function