Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jer jer is offline
external usenet poster
 
Posts: 8
Default looping ... date formula ...

I am not sure if this is for here or worksheet function
group so I am posting twice. I am relatively new to
writing code and would greatly appreciate any help with
this. I have inherited a worksheet with 12 columns
(comprising payment amounts, reducing balances,
categories, etc). Column 11 holds a reference number and
against this reference number there are 48 monthly
payments to be made. Payments are to be made on the first
of every month. Rather than create the formula and drag
it down, the spreadsheet contains 100 reference numbers, I
was looking for a way to to this
automatically. I have used the following code but I keep
getting #NAME? error. cells(9,2) should be 01-June-02,
cells(9,3) should be 01-July-02, etc I am guessing that
the problem is how I am referencing the date field. I am
also adding a sample of th worksheet

1 2 3 4
5 6 7 8
9 10 11 12

$165,000.00 ($2,759.22) $165,000.00 20
$1,213.70 $1,545.52 $163,454.48
01-May-02 P28 8202 446
$163,454.48 ($4,138.83) $159,315.65 30
$1,757.82 $2,381.01 $161,073.47 1
#NAME? P28 8202 446
$161,073.47 ($4,138.83) $156,934.64 30
$1,731.55 $2,407.28 $158,666.19 2
#NAME? P28 8202 446
$158,666.19 ($4,138.83) $154,527.36 30
$1,704.99 $2,433.84 $156,232.35 3
#NAME? P28 8202 446


Dim cell As Range
Set cell = ActiveWorkbook.Worksheets("Sheet1").Cells
(3, 12)

Do Until IsEmpty(cell.Value)
If cell.Offset(0, -1) = 8202# Then

Do Until cell.Offset(0, -5) = 0 'Balance of
payments due

cell.Offset(0, -3).Value = "=Date(Year
(cell.Offset(-1, -3)), Month(cell.Offset(-1, -3)) + 1, Day
(cell.Offset(-1, -3)))"

Set cell = cell.Offset(1, 0)
Loop
End If
Set cell = cell.Offset(1, 0)
Loop

Any suggestions. Any help would be greatly appreciated.
Thanks in advance
jer

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default looping ... date formula ...

You might try replacing the part of your code that enters the formula with
this:

With Cell
.Offset(0, -3).Value = "=Date(Year(" & .Offset(-1, -3).Address _
& "),Month(" & .Offset(-1, -3).Address _
& ") +1, Day(" & .Offset(-1, -3).Address & "))"
End With

Your code enters everything to the right of the "=" as literal text.
Literal VBA code like "cell.Offset(-1, -3))" has no meaning in a worksheet
cell. You have to enter what that code evaluates to.

--
Jim Rech
Excel MVP


  #3   Report Post  
Posted to microsoft.public.excel.programming
jer jer is offline
external usenet poster
 
Posts: 1
Default looping ... date formula ...

Jim, Thank much ... works like a charm...
have a great day!!!
jer

-----Original Message-----
You might try replacing the part of your code that enters

the formula with
this:

With Cell
.Offset(0, -3).Value = "=Date(Year(" & .Offset(-1, -

3).Address _
& "),Month(" & .Offset(-1, -3).Address _
& ") +1, Day(" & .Offset(-1, -3).Address & "))"
End With

Your code enters everything to the right of the "=" as

literal text.
Literal VBA code like "cell.Offset(-1, -3))" has no

meaning in a worksheet
cell. You have to enter what that code evaluates to.

--
Jim Rech
Excel MVP


.

Reply
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
creating a looping formula between different spreadsheets Jon Buonocore New Users to Excel 0 March 28th 06 04:29 AM
looping with formula inside a.ekster Excel Programming 1 October 27th 03 03:30 AM
looping formula - r1c1 problem - Con't MDC[_2_] Excel Programming 0 October 22nd 03 11:42 PM
looping formula - r1c1 problem MDC[_2_] Excel Programming 2 October 22nd 03 11:13 PM
looping Ranking formula - R[1]C[1] MDC[_2_] Excel Programming 2 October 22nd 03 04:56 AM


All times are GMT +1. The time now is 11:10 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"