vba variable range in a formula

F

fnwcanada

I am trying to enter a formula into a range of cells and in the
formula the row range also has to change. My error seems to be with
"range1" and it is not returning a cell but says "range1". Any
ideas???

Dim rw As Integer, range1 As Range, range2 As Range
For rw = 2 To 8
Set range1 = ActiveSheet.Cells(rw, 4)
Set range2 = ActiveSheet.Cells(rw, 6)
range2.formula = "=SUMPRODUCT(('271500.xls'!
category_271500= " & range1 & ")*('271500.xls'!amount_271500))"
Next rw
 

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