PC Review


Reply
Thread Tools Rate Thread

Creating Intermediate Date Values - New Problem

 
 
Jim Berglund
Guest
Posts: n/a
 
      29th Apr 2007
I'm using the following code (provided by Joel, with my great appreciation)
to create a set of prorated dates between two dates for a series of dates.
eg
Column L
9/3/1999
..
..
..
..
..
..
..
10/6/2004
4/2/1996
..
..
..
4/30/2007
etc.

I. tried to use it on another similar worksheet but ran into a type mismatch
error 13 problem after it had run through the first set successfully. I have
tried to correct it withot success.

Any ideas will be appreciated...

Thanks
Jim Berglund


Sub Prorate()

LastRow = Cells(Rows.Count, 1).End(xlUp).Row

First = True
For RowCount = 2 To LastRow
If IsEmpty(Cells(RowCount, "A")) Then 'if last row was empty use todays
date to prorate
If IsEmpty(Cells(RowCount - 1, "L")) Then 'Use last NewDate to
prorate
OldDate = NewDate
NewDate = Now()
DeltaDate = (NewDate - OldDate) / _
(RowCount - OldRow)
'fill in prorated dates
For RowCount2 = OldRow To (RowCount - 1)

MyDate = Cells(RowCount2 - 1, "L") + _
DeltaDate
Cells(RowCount2, "L") = MyDate
Next RowCount2

End If
First = True
Else
If First = True Then

OldDate = Cells(RowCount, "L")
OldRow = RowCount
First = False
Else
If Not IsEmpty(Cells(RowCount, "L")) Then
NewDate = Cells(RowCount, "L")
DeltaDate = (NewDate - OldDate) / (RowCount - OldRow)
'fill in prorated dates
For RowCount2 = (OldRow + 1) To (RowCount - 1)

MyDate = Cells(RowCount2 - 1, "L") + _
DeltaDate
Cells(RowCount2, "L") = MyDate
Next RowCount2
OldDate = NewDate
OldRow = RowCount
End If
End If
End If

Next RowCount



End Sub


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      29th Apr 2007
Jim,

Try stepping through the code and tell us where the code has an error and
what the values might be.

Thanks,
Barb

"Jim Berglund" wrote:

> I'm using the following code (provided by Joel, with my great appreciation)
> to create a set of prorated dates between two dates for a series of dates.
> eg
> Column L
> 9/3/1999
> ..
> ..
> ..
> ..
> ..
> ..
> ..
> 10/6/2004
> 4/2/1996
> ..
> ..
> ..
> 4/30/2007
> etc.
>
> I. tried to use it on another similar worksheet but ran into a type mismatch
> error 13 problem after it had run through the first set successfully. I have
> tried to correct it withot success.
>
> Any ideas will be appreciated...
>
> Thanks
> Jim Berglund
>
>
> Sub Prorate()
>
> LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>
> First = True
> For RowCount = 2 To LastRow
> If IsEmpty(Cells(RowCount, "A")) Then 'if last row was empty use todays
> date to prorate
> If IsEmpty(Cells(RowCount - 1, "L")) Then 'Use last NewDate to
> prorate
> OldDate = NewDate
> NewDate = Now()
> DeltaDate = (NewDate - OldDate) / _
> (RowCount - OldRow)
> 'fill in prorated dates
> For RowCount2 = OldRow To (RowCount - 1)
>
> MyDate = Cells(RowCount2 - 1, "L") + _
> DeltaDate
> Cells(RowCount2, "L") = MyDate
> Next RowCount2
>
> End If
> First = True
> Else
> If First = True Then
>
> OldDate = Cells(RowCount, "L")
> OldRow = RowCount
> First = False
> Else
> If Not IsEmpty(Cells(RowCount, "L")) Then
> NewDate = Cells(RowCount, "L")
> DeltaDate = (NewDate - OldDate) / (RowCount - OldRow)
> 'fill in prorated dates
> For RowCount2 = (OldRow + 1) To (RowCount - 1)
>
> MyDate = Cells(RowCount2 - 1, "L") + _
> DeltaDate
> Cells(RowCount2, "L") = MyDate
> Next RowCount2
> OldDate = NewDate
> OldRow = RowCount
> End If
> End If
> End If
>
> Next RowCount
>
>
>
> End Sub
>
>
>

 
Reply With Quote
 
Jim Berglund
Guest
Posts: n/a
 
      29th Apr 2007
It occurs in the row surrounded with asterisks. It completes from the first
variable (9/3/1999) to the second(10/6/2004) and then I get the error

Thanks for your interest and help.
Jim

"Barb Reinhardt" <(E-Mail Removed)> wrote in message
news:8420E17B-F715-400F-A970-(E-Mail Removed)...
> Jim,
>
> Try stepping through the code and tell us where the code has an error and
> what the values might be.
>
> Thanks,
> Barb
>
> "Jim Berglund" wrote:
>
>> I'm using the following code (provided by Joel, with my great
>> appreciation)
>> to create a set of prorated dates between two dates for a series of
>> dates.
>> eg
>> Column L
>> 9/3/1999
>> ..
>> ..
>> ..
>> ..
>> ..
>> ..
>> ..
>> 10/6/2004
>> 4/2/1996
>> ..
>> ..
>> ..
>> 4/30/2007
>> etc.
>>
>> I. tried to use it on another similar worksheet but ran into a type
>> mismatch
>> error 13 problem after it had run through the first set successfully. I
>> have
>> tried to correct it withot success.
>>
>> Any ideas will be appreciated...
>>
>> Thanks
>> Jim Berglund
>>
>>
>> Sub Prorate()
>>
>> LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>
>> First = True
>> For RowCount = 2 To LastRow
>> If IsEmpty(Cells(RowCount, "A")) Then 'if last row was empty use
>> todays
>> date to prorate
>> If IsEmpty(Cells(RowCount - 1, "L")) Then 'Use last NewDate to
>> prorate
>> OldDate = NewDate
>> NewDate = Now()
>> DeltaDate = (NewDate - OldDate) / _
>> (RowCount - OldRow)
>> 'fill in prorated dates
>> For RowCount2 = OldRow To (RowCount - 1)
>>
>> MyDate = Cells(RowCount2 - 1, "L") + _
>> DeltaDate
>> Cells(RowCount2, "L") = MyDate
>> Next RowCount2
>>
>> End If
>> First = True
>> Else
>> If First = True Then
>>
>> OldDate = Cells(RowCount, "L")
>> OldRow = RowCount
>> First = False
>> Else
>> If Not IsEmpty(Cells(RowCount, "L")) Then
>> NewDate = Cells(RowCount, "L")

**********************************
>> DeltaDate = (NewDate - OldDate) / (RowCount - OldRow)

***********************************
>> 'fill in prorated dates
>> For RowCount2 = (OldRow + 1) To (RowCount - 1)
>>
>> MyDate = Cells(RowCount2 - 1, "L") + _
>> DeltaDate
>> Cells(RowCount2, "L") = MyDate
>> Next RowCount2
>> OldDate = NewDate
>> OldRow = RowCount
>> End If
>> End If
>> End If
>>
>> Next RowCount
>>
>>
>>
>> End Sub
>>
>>
>>



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      29th Apr 2007
If you have asterisks in the cell with the dates, then that cell isn't a date
anymore--it's just plain old text. And excel (and VBA) doesn't like to do
arithmetic with plain text.

Can you put the asterisks in a separate column. It would make doing arithmetic
much easier (in excel and VBA).

Jim Berglund wrote:
>
> It occurs in the row surrounded with asterisks. It completes from the first
> variable (9/3/1999) to the second(10/6/2004) and then I get the error
>
> Thanks for your interest and help.
> Jim
>
> "Barb Reinhardt" <(E-Mail Removed)> wrote in message
> news:8420E17B-F715-400F-A970-(E-Mail Removed)...
> > Jim,
> >
> > Try stepping through the code and tell us where the code has an error and
> > what the values might be.
> >
> > Thanks,
> > Barb
> >
> > "Jim Berglund" wrote:
> >
> >> I'm using the following code (provided by Joel, with my great
> >> appreciation)
> >> to create a set of prorated dates between two dates for a series of
> >> dates.
> >> eg
> >> Column L
> >> 9/3/1999
> >> ..
> >> ..
> >> ..
> >> ..
> >> ..
> >> ..
> >> ..
> >> 10/6/2004
> >> 4/2/1996
> >> ..
> >> ..
> >> ..
> >> 4/30/2007
> >> etc.
> >>
> >> I. tried to use it on another similar worksheet but ran into a type
> >> mismatch
> >> error 13 problem after it had run through the first set successfully. I
> >> have
> >> tried to correct it withot success.
> >>
> >> Any ideas will be appreciated...
> >>
> >> Thanks
> >> Jim Berglund
> >>
> >>
> >> Sub Prorate()
> >>
> >> LastRow = Cells(Rows.Count, 1).End(xlUp).Row
> >>
> >> First = True
> >> For RowCount = 2 To LastRow
> >> If IsEmpty(Cells(RowCount, "A")) Then 'if last row was empty use
> >> todays
> >> date to prorate
> >> If IsEmpty(Cells(RowCount - 1, "L")) Then 'Use last NewDate to
> >> prorate
> >> OldDate = NewDate
> >> NewDate = Now()
> >> DeltaDate = (NewDate - OldDate) / _
> >> (RowCount - OldRow)
> >> 'fill in prorated dates
> >> For RowCount2 = OldRow To (RowCount - 1)
> >>
> >> MyDate = Cells(RowCount2 - 1, "L") + _
> >> DeltaDate
> >> Cells(RowCount2, "L") = MyDate
> >> Next RowCount2
> >>
> >> End If
> >> First = True
> >> Else
> >> If First = True Then
> >>
> >> OldDate = Cells(RowCount, "L")
> >> OldRow = RowCount
> >> First = False
> >> Else
> >> If Not IsEmpty(Cells(RowCount, "L")) Then
> >> NewDate = Cells(RowCount, "L")

> **********************************
> >> DeltaDate = (NewDate - OldDate) / (RowCount - OldRow)

> ***********************************
> >> 'fill in prorated dates
> >> For RowCount2 = (OldRow + 1) To (RowCount - 1)
> >>
> >> MyDate = Cells(RowCount2 - 1, "L") + _
> >> DeltaDate
> >> Cells(RowCount2, "L") = MyDate
> >> Next RowCount2
> >> OldDate = NewDate
> >> OldRow = RowCount
> >> End If
> >> End If
> >> End If
> >>
> >> Next RowCount
> >>
> >>
> >>
> >> End Sub
> >>
> >>
> >>


--

Dave Peterson
 
Reply With Quote
 
Jim Berglund
Guest
Posts: n/a
 
      30th Apr 2007
Barb, I created a note in Outlook that has screenshots and the actual files
I'm using. Can I please send it to you?

Jim Berglund

"Barb Reinhardt" <(E-Mail Removed)> wrote in message
news:8420E17B-F715-400F-A970-(E-Mail Removed)...
> Jim,
>
> Try stepping through the code and tell us where the code has an error and
> what the values might be.
>
> Thanks,
> Barb
>
> "Jim Berglund" wrote:
>
>> I'm using the following code (provided by Joel, with my great
>> appreciation)
>> to create a set of prorated dates between two dates for a series of
>> dates.
>> eg
>> Column L
>> 9/3/1999
>> ..
>> ..
>> ..
>> ..
>> ..
>> ..
>> ..
>> 10/6/2004
>> 4/2/1996
>> ..
>> ..
>> ..
>> 4/30/2007
>> etc.
>>
>> I. tried to use it on another similar worksheet but ran into a type
>> mismatch
>> error 13 problem after it had run through the first set successfully. I
>> have
>> tried to correct it withot success.
>>
>> Any ideas will be appreciated...
>>
>> Thanks
>> Jim Berglund
>>
>>
>> Sub Prorate()
>>
>> LastRow = Cells(Rows.Count, 1).End(xlUp).Row
>>
>> First = True
>> For RowCount = 2 To LastRow
>> If IsEmpty(Cells(RowCount, "A")) Then 'if last row was empty use
>> todays
>> date to prorate
>> If IsEmpty(Cells(RowCount - 1, "L")) Then 'Use last NewDate to
>> prorate
>> OldDate = NewDate
>> NewDate = Now()
>> DeltaDate = (NewDate - OldDate) / _
>> (RowCount - OldRow)
>> 'fill in prorated dates
>> For RowCount2 = OldRow To (RowCount - 1)
>>
>> MyDate = Cells(RowCount2 - 1, "L") + _
>> DeltaDate
>> Cells(RowCount2, "L") = MyDate
>> Next RowCount2
>>
>> End If
>> First = True
>> Else
>> If First = True Then
>>
>> OldDate = Cells(RowCount, "L")
>> OldRow = RowCount
>> First = False
>> Else
>> If Not IsEmpty(Cells(RowCount, "L")) Then
>> NewDate = Cells(RowCount, "L")
>> DeltaDate = (NewDate - OldDate) / (RowCount - OldRow)
>> 'fill in prorated dates
>> For RowCount2 = (OldRow + 1) To (RowCount - 1)
>>
>> MyDate = Cells(RowCount2 - 1, "L") + _
>> DeltaDate
>> Cells(RowCount2, "L") = MyDate
>> Next RowCount2
>> OldDate = NewDate
>> OldRow = RowCount
>> End If
>> End If
>> End If
>>
>> Next RowCount
>>
>>
>>
>> End Sub
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide Intermediate Levels in Date Dimension Domenick Microsoft Excel Misc 0 16th Dec 2009 10:09 PM
How to display the intermediate values =?Utf-8?B?SmFjaw==?= Microsoft Access Form Coding 2 22nd Jun 2007 08:13 PM
Creating intermediate date values Jim Berglund Microsoft Excel Programming 13 30th Apr 2007 01:04 AM
How to get intermediate values from smooth graph in Excel ? =?Utf-8?B?VHVzaGFy?= Microsoft Excel Charting 6 13th Feb 2006 08:39 PM
need to calculate intermediate values Chris Alexander Microsoft Excel Worksheet Functions 3 18th Aug 2004 02:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:56 PM.