LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Inscrutable error

I'm having a problem I can't solve.

Please do the following:
In a new worksheet
Fill Column A with any value down to row 36

In column L, place dates, as follows(row# is not important):
Row L
2 10/10/1993
3
4
5
6 5/4/2005
7 3/3/1993
8
9
10 12/3/2007
11 6/23/2000
12
13
14 8/8/2007
15 4/4/2001
etc.
for 36 rows ( the first of the pairs needs to be lower than the second, with
any number of blank cells between them)

Then run this code
Sub Prorate_Dates()

Dim RowCount, RowCount2, OldRow As Integer
Dim OldDate, NewDate, DeltaDate, MyDate As Variant
'On Error Resume Next
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 'Is it the first line of the series?
Else
If First = True Then

OldDate = Cells(RowCount, "L")
OldRow = RowCount
First = False
Else
If Not IsEmpty(Cells(RowCount, "L")) Then 'if the cell is empty,
go to the nect cell
NewDate = Cells(RowCount, "L") 'Otherwise select the last
date for the series
DeltaDate = (NewDate - OldDate) / (RowCount - OldRow) 'Calculate
the prorated difference between first & last and divide by the number of
empty lines

For RowCount2 = (OldRow + 1) To (RowCount - 1) 'fill in prorated
dates
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

It generates an error around line 26, and I can't understand why.

Please help!

Thanks
Jim Berglund


 
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
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Form Err.Raise error not trapped by entry procedure error handler [email protected] Excel Programming 1 February 8th 06 10:19 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


All times are GMT +1. The time now is 04:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"