Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

Calculating column based on formula

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
S Himmelrich - 22 Jan 2008 17:17 GMT
I'm getting an "Application-defined or object-defined error" on the
line below that I've identified...can anyone help me out on this?

Dim last7 As Long
   last7 = Worksheets("Working Sheet").Cells(Rows.Count,
"J").End(xlUp).Row
   Range("K1").Formula = "=IF(SUM('Working Sheet'!RC[1]/MACRO!G
$11$)),"",SUM('Working Sheet'!RC[1]/MACRO!G$11$)" <---LINE WITH ERROR
   Range("K1").AutoFill Destination:=Range("K1:K" & last7)
Rick Rothstein (MVP - VB) - 22 Jan 2008 18:32 GMT
The $ signs are on the wrong side....

Range("K1").Formula = "=IF(SUM('Working
Sheet'!RC[1]/MACRO!$G$11)),"",SUM('Working Sheet'!RC[1]/MACRO!$G$11)"

Rick

> I'm getting an "Application-defined or object-defined error" on the
> line below that I've identified...can anyone help me out on this?
[quoted text clipped - 5 lines]
> $11$)),"",SUM('Working Sheet'!RC[1]/MACRO!G$11$)" <---LINE WITH ERROR
>    Range("K1").AutoFill Destination:=Range("K1:K" & last7)
Dave Peterson - 22 Jan 2008 18:36 GMT
You're mixing R1C1 reference style with A1 reference style.

If you decide to use all R1C1 reference style, then use .formulaR1C1 =

(and just a little help:  $g$11 is r11c7)

> I'm getting an "Application-defined or object-defined error" on the
> line below that I've identified...can anyone help me out on this?
[quoted text clipped - 5 lines]
> $11$)),"",SUM('Working Sheet'!RC[1]/MACRO!G$11$)" <---LINE WITH ERROR
>     Range("K1").AutoFill Destination:=Range("K1:K" & last7)

Signature

Dave Peterson

Dave Peterson - 22 Jan 2008 18:44 GMT
Ps.  You have a couple of other things wrong with your formula.

If you need to have double quotes show up in your formula, then you'll need to
double them in your code.

And you don't need =sum().  You're just dividing one number by another.

And it looks like you're putting this all on Working Sheet, if that's true, then
you could try this:

   Dim last7 As Long
   With Worksheets("working sheet")
       last7 = .Cells(.Rows.Count, "J").End(xlUp).Row
       .Range("K1:K" & last7).FormulaR1C1 _
           = "=IF(RC[1]/MACRO!r11c7,"""",RC[1]/MACRO!r11c7)"
   End With
   
I'm not sure what you're doing with that formula, but maybe you were checking
for errors???

= "=IF(iserror(RC[1]/MACRO!r11c7),"""",RC[1]/MACRO!r11c7)"

is how I'd check.

> I'm getting an "Application-defined or object-defined error" on the
> line below that I've identified...can anyone help me out on this?
[quoted text clipped - 5 lines]
> $11$)),"",SUM('Working Sheet'!RC[1]/MACRO!G$11$)" <---LINE WITH ERROR
>     Range("K1").AutoFill Destination:=Range("K1:K" & last7)

Signature

Dave Peterson

S Himmelrich - 22 Jan 2008 20:48 GMT
Solution:

   Dim rng As Range
   Set rng = Range(Cells(1, "D"), Cells(Rows.Count, "D").End(xlUp))
   rng.Offset(0, 7).Formula = "=IF(J1="""","""",SUM(J1/MACRO!$G$11))"
Dave Peterson - 22 Jan 2008 22:11 GMT
What happens if Macro!G11 is empty or is equal to 0?
Why use the =sum() function.
Why did the column change from J to D?

> Solution:
>
>     Dim rng As Range
>     Set rng = Range(Cells(1, "D"), Cells(Rows.Count, "D").End(xlUp))
>     rng.Offset(0, 7).Formula = "=IF(J1="""","""",SUM(J1/MACRO!$G$11))"

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.