LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Formula in macro gives "Run-time error '1004':"


I'm trying to set a macro so that if a person changes something in column D
on any row it automatically adds the formula in the corresponding cell in Row
E to do the maths.

This is to make it more idiot proof so if somebody adds a row etc. it sorts
out the formula when they start filling in.

But the below now gives me the above error code and "Application-defined or
Object-defined error" message.

I have other macros in the excel spreadsheet as well....

Help!


Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Range(Target.Address), Range("A:E")) _
Is Nothing And Target.Row < 1 Then

Dim r As Long
r = Target.Row

If Cells(r, "D").Value < "" Then

' the below adds in the formula in column E


Cells(r, "E").FormulaR1C1 =
"=IF(IF(RC[-1]="",RC[-2],RC[-1])=0,"",IF(RC[-1]="",RC[-2],RC[-1]))"

End If
End If


End Sub
 
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
how do I correct a "run time error 1004-unable to open" problem? BillR Excel Programming 1 August 26th 08 07:21 PM
"run-time error '1004' - select method of range failed" maemi weirdoke Excel Programming 2 March 5th 08 03:15 PM
Run-time error "1004" Select method of range class failed Tallan Excel Discussion (Misc queries) 3 March 7th 07 05:22 PM
Run time error 1004: "No list was found.." hachiroku[_5_] Excel Programming 1 May 22nd 06 12:53 PM
"Run-time error '1004'" Method 'Range' of object '_global' failed. haisat[_2_] Excel Programming 0 October 20th 03 12:13 PM


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