Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Code returns TRUE instead of value

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Code returns TRUE instead of value

Loren,
This line
Cells(Row, Col) = ActiveCell.Value = 0
evaluates "ActiveCell.Value = 0", which will either True or False. It is
this answer that you put in Cells(Row, Col).Value.

From your description "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.", I would guess you mean:
Cells(Row, Col).Value = 0

NickHK

"loren.pottinger"
groups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Code returns TRUE instead of value

It is not executing my If-Then-Else statement.
It seems the only statement being executed is: Cells(Row, Col).Value =
Range("K" & Row) and I only want it to do that if the condition is
true, and put a 0 in each cell in the range if it is false. Can someone
please look at my code and help me to get it to execute the
If-Then-Else statement. Thank you. Updated code as follows:

Sub Fill()

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

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

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

If TestDate < Range("I" & Row).Value Then
Cells(Row, Col).Value = Range("K" & Row)
Range("F" & Row).Value = Range("F" & Row).Value - 1

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

End If
End With

Next Row
Next Col
End Sub




Dave Peterson wrote:
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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Code returns TRUE instead of value

Another multipost.



"loren.pottinger" wrote:

It is not executing my If-Then-Else statement.
It seems the only statement being executed is: Cells(Row, Col).Value =
Range("K" & Row) and I only want it to do that if the condition is
true, and put a 0 in each cell in the range if it is false. Can someone
please look at my code and help me to get it to execute the
If-Then-Else statement. Thank you. Updated code as follows:

Sub Fill()

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

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

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

If TestDate < Range("I" & Row).Value Then
Cells(Row, Col).Value = Range("K" & Row)
Range("F" & Row).Value = Range("F" & Row).Value - 1

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

End If
End With

Next Row
Next Col
End Sub

Dave Peterson wrote:
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


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Code returns TRUE instead of value

I waited like 15 mins before doing so............................It's
kinda crunch time around here. I apologize.

Dave Peterson wrote:
Another multipost.



"loren.pottinger" wrote:

It is not executing my If-Then-Else statement.
It seems the only statement being executed is: Cells(Row, Col).Value =
Range("K" & Row) and I only want it to do that if the condition is
true, and put a 0 in each cell in the range if it is false. Can someone
please look at my code and help me to get it to execute the
If-Then-Else statement. Thank you. Updated code as follows:

Sub Fill()

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

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

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

If TestDate < Range("I" & Row).Value Then
Cells(Row, Col).Value = Range("K" & Row)
Range("F" & Row).Value = Range("F" & Row).Value - 1

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

End If
End With

Next Row
Next Col
End Sub

Dave Peterson wrote:
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


--

Dave Peterson


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Code returns TRUE instead of value

It may be crunch time for you, but you're wasting your time by having to check
multiple newsgroups.

And you're wasting the time of responders if the answer was already posted.

My post is more of a warning to others. They may not want to bother if you have
a response elsewhere.

"loren.pottinger" wrote:

I waited like 15 mins before doing so............................It's
kinda crunch time around here. I apologize.

Dave Peterson wrote:
Another multipost.



"loren.pottinger" wrote:

It is not executing my If-Then-Else statement.
It seems the only statement being executed is: Cells(Row, Col).Value =
Range("K" & Row) and I only want it to do that if the condition is
true, and put a 0 in each cell in the range if it is false. Can someone
please look at my code and help me to get it to execute the
If-Then-Else statement. Thank you. Updated code as follows:

Sub Fill()

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

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

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

If TestDate < Range("I" & Row).Value Then
Cells(Row, Col).Value = Range("K" & Row)
Range("F" & Row).Value = Range("F" & Row).Value - 1

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

End If
End With

Next Row
Next Col
End Sub

Dave Peterson wrote:
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


--

Dave Peterson


--

Dave Peterson
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
=IF(test,true,false) only ever returns "true"? TagTech Excel Worksheet Functions 5 December 10th 08 03:04 PM
Any number above 15 returns false when it should be true tlaurie777 Excel Worksheet Functions 2 September 26th 07 05:02 PM
An if statment tat returns a true blank D Excel Worksheet Functions 4 August 29th 07 02:48 PM
If Statement returns true when false? Eric Excel Discussion (Misc queries) 3 September 11th 06 01:58 PM
Code returns TRUE instead of value loren.pottinger Excel Discussion (Misc queries) 2 September 5th 06 05:21 PM


All times are GMT +1. The time now is 11:34 PM.

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

About Us

"It's about Microsoft Excel"