It is actually usually pretty easy.
You can use regular references: Range("A1")= Range ("C10")
Will put the value of cell C10 into cell A1
Relative references are a different. In
VB the format Cells(R,C) can be used
Range ("A1") = Cells(Range("A1").Row,2)
Will put the value of B2 into cell A1.
This format can also be looped
For A=1 to 10
Cells(A,1)=Cells(A,2)
Next A
Would put the value of B1-B10 into cells A1-A10.
You can also use the & operator, you will need to make sure all values are
strings using the Cstr("") function like this.
For A=1 to 2
Cells(R,2)=Cstr(Cells(R,12))&Cstr(Cells(R,10))&Cst r(Cells(R,17))
Next A
Your second formula is a error in that you are putting a formula into a
offset ,-1 from column 1, but the logic would be something like this (changed
to column A)
For A=1 to 2
If Cells(4,13)=0 then
Cells(A,1)="Data?"
Else
Cells(A,1)=Cells(A,4)/Cells(4,13)
End If
Next A
--
If this helps, please remember to click yes.
"Roger on Excel" wrote:
I use the following type of code to place formulas in cells :
For Each cell In Range("A1:A2")
cell.Offset(, 1).FormulaR1C1 = "=RC[10]&RC[8]&RC[15]"
'Equiv
cell.Offset(, -1).FormulaR1C1 =
"=IF(ISERROR(RC[5]/r4c13),""Data?"",RC[3]/r4c13)"
Next
This works fine, however my question is whether one can perform the
calculations in the code and just place the result into the cells?
I guess this may require learning a whole new syntax for coding the
equations, but I was wondering if someone could give me some pointers?
Many Thanks,
Roger