LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Code returns TRUE instead of value

You have several replies to your several posts.

Please don't multipost.

"loren.pottinger" wrote:

Essentially what I am trying to do is this:

I am trying to calculate depreciation.

I use the DateAdd function to add x number of months(Cell "F & Row that
is active") to the acquisition date(Cell "H & Row that is active" of
an asset.

If the sum of those dates is greater than the End of life (Cell "I &
Row that is active") of that asset then there is a payment for that
month and the value in Range("K" & Row) is place in the active cell
until the entire cell range from M7 to AC63 is filled.

If the sum of those dates is not greater the End of life (Cell "I & Row
that is active") of that asset then a value of zero is place in that
cell.

In either case the value in (Cell "F & Row that is active")
decremented by 1 for the next time the loop is run.

It runs, and the range is being filled, but there is not supposed to be
a payment for every cell in the range. There are no zeros for when the
condition is false.

Additionally, the entire Column "M" only has the word TRUE and not a
numerical value. My macro is as follows. Please help.

Sub Fill()

Dim TestDate As Date
Dim Col As Integer
Dim Row As Long

For Col = 13 To 29
For Row = 7 To 63

TestDate = DateAdd("m", Range("F" & Row), _
Range("H" & Row))

If TestDate < Range("I" & Row) Then

Range("K" & Row).Copy
Cells(Row, Col) = Range("K" & Row)
Range("F" & Row).Value = Range("F" & Row).Value - 1

Else
Cells(Row, Col) = ActiveCell.Value = 0
Range("F" & Row).Value = Range("F" & Row).Value - 1
End If

Next Row
Next Col
End Sub


--

Dave Peterson
 
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
Disable CUT via toolbars or shortcut keys sparx Excel Discussion (Misc queries) 0 April 30th 06 08:34 PM
Disable "Cut" only sparx Excel Discussion (Misc queries) 2 April 29th 06 05:08 PM
Help in VBA code! Martin Excel Discussion (Misc queries) 5 April 19th 06 11:19 AM
First part of "IF" function returns false even if true. ?? Bill R Excel Worksheet Functions 4 September 5th 05 08:11 PM
Using other workbooks.. DavidMunday Excel Worksheet Functions 2 July 1st 05 07:35 AM


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