storing an equation in a macro

S

sowetoddid

Is it possible to store an equation such as

=sum(C1:C4)

in a macro and have the macro paste the formula into the first 50
cells of column A
 
F

Frank Kabel

Hi
try the following
sub foo()
dim f_str as string
f_str="=SUM(R[0]C[2]:R[3]C[2])
range("A1:A500").formulaR1C1=f_str
end sub
 
B

Bob Phillips

Range("A1").Formula = "=SUM($C$1:$C$4)"
Range("A1").AutoFill Range("A1:A500")


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
S

sowetoddid

I am trying to store this equation into the macro and it gives me a
"application-defined or object-defined error".


=IF(ISBLANK(B1),"",VLOOKUP(B1,'C:\Documents and Settings\jdoe\M
Documents\[Master Inventory 2-13-04.xls]Master by RC
Number'!$C$1:$E$189,3,0))


Any ideas on what to change
 
B

Bob Phillips

Try

="=IF(ISBLANK(B1),"""",VLOOKUP(B1,'C:\Documents and Settings\jdoe\My
Documents\[Master Inventory 2-13-04.xls]Master by RCS
Number'!$C$1:$E$189,3,0))"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top