Consulting

Results 1 to 3 of 3

Thread: Solved: Insert formula error.

  1. #1
    VBAX Mentor Marcster's Avatar
    Joined
    Jun 2005
    Posts
    434
    Location

    Question Solved: Insert formula error.

    Hello people,

    When I run the following:
    [VBA]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[/VBA]
    It displays an error:
    Run time error: '1004':
    Application-defined or object-defined error

    Any ideas why?. Any fixes?.

    I've also tried:
    [VBA]
    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[/VBA]
    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.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]
    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
    [/vba]

  3. #3
    VBAX Mentor Marcster's Avatar
    Joined
    Jun 2005
    Posts
    434
    Location
    Quote Originally Posted by xld
    [vba]
    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
    [/vba]
    Thanks again XLD

    Marcster.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •