PDA

View Full Version : Solved: Insert formula error.



Marcster
01-16-2006, 06:00 AM
Hello people,

When I run the following:
Sub InsertFormulas
Dim FinalRow As Integer
FinalRow = Cells(65536, 1).End(xlUp).Row
Range("I2:I" & FinalRow).Formula = "=IF(C2='','No Date',TODAY()-C2)"
End Sub
It displays an error:
Run time error: '1004':
Application-defined or object-defined error

Any ideas why?. Any fixes?.

I've also tried:

Sub InsertFormulas2()

Dim FinalRow As Integer
FinalRow = Cells(65536, 1).End(xlUp).Row

With Range("I2:I" & FinalRow)
.FormulaR1C1 = "=IF(C2='','No Date',TODAY()-C2)"
.Value = .Value
End With
End Sub
But that shows same error.

Column C contains dates.
If column C is blank then column I should say 'No Date'
Else it should display how many days from today.

Thanks,
Marcster.

Bob Phillips
01-16-2006, 06:18 AM
Sub InsertFormulas()
Dim FinalRow As Integer
FinalRow = Cells(65536, 1).End(xlUp).Row
Range("I2:I" & FinalRow).Formula = "=IF(C2="""",""No Date"",TODAY()-C2)"
End Sub

Marcster
01-16-2006, 06:57 AM
Sub InsertFormulas()
Dim FinalRow As Integer
FinalRow = Cells(65536, 1).End(xlUp).Row
Range("I2:I" & FinalRow).Formula = "=IF(C2="""",""No Date"",TODAY()-C2)"
End Sub


Thanks again XLD :yes
:beerchug:
Marcster.