Macro to autofill formula in every row

S

Slim

Hello,

I'm attempting to write a macro that will insert a formula starting in
cell "C13", in every row (straight down the C column), to the end of the
range of the spreadsheet.

The formula I want to enter is
"=IF(AND(D13="",E13=""),"",IF(D13="","50","40"))"

Is there anyone that could kindly help me with this?

Thanks.
 
S

slimshady26

Thank you very much.

Works exactly as needed!


Tom said:
set rng1 = Activesheet.UsedRange
Set rng = Range("C13",Cells(rng1(rng1.count).row,"C"))
rng.Formula = "=IF(AND(D13="""",E13=""""),"""",IF(D13="""",50,40))"

If you really want the 50 and 40 to be strings

rng.Formula = "=IF(AND(D13="""",E13=""""),"""",IF(D13="""",""50"",""40""))"


if we could count on column A (as an example) to have a value in the last
row you want to use you could do


Set rng = Range("C13",Cells(Cells(rows.count,1).End(xlup).row,"C"))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top