Creating Loop to Paste Array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I currently have a macro that copy pastes a formula based on a predetermined
cell range. Is there a way to create a loop that will find cells that have
values in Col B and Col C and paste the formula in Col N.

Macro Example: (Replace "=Range("N2:N100)) with loop.

ActiveCell.FormulaR1C1 = _
"=IF(RC13="""","""",SUMIF(R2C2:R500C2,R2C13:R100C13,R2C3:R500C3))"
Range("N2").Select
Selection.AutoFill Destination:=Range("N2:N100"), Type:=xlFillDefault
Range("N2:N100").Select
ActiveWindow.ScrollRow = 1

Thanks
 
dim myCell as range
with activesheet
for each mycell in .range("n2:n100")
if isempty(.cells(mycell.row,"B")) _
and isempty(.cells(mycell.row,"C")) then
'both empty, do nothing
else
mycell.formular1c1 = "yourformulahere"
end if
next mycell
end with

===
I wasn't sure if both B and C had to be empty or just one (or the other).

Change that AND to Or if you want.
 

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

Back
Top