Insert variable cell in the formula

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

Guest

Hi,

I try to insert a formula to multiply two rows, like A1*C1, A2*C2....., how
can I do that by using a FOR loop in the marco?

Thanks.

Gian
 
You don't need to loop
Assume you want the formula in column D

set rng = Range(Cells(1,1),Cells(rows.count,1).End(xlup))
rng.offset(0,3).Formula = "=A1*C1"
 
Thanks Tom.

I just curious, it's possible to put the variable in the formula, like
"=chr(65)&1 * chr(67)&1"
 
"=" & chr(65) & "1" & "*" & chr(67) & "1"

testing from the immediate window:

? "=" & chr(65) & "1" & "*" & chr(67) & "1"
=A1*C1

But I am not sure that is what you are trying to achieve.
 
Hi Tom,

This is exactly what I want. Appreciate your help.

BTW, what the "End(xlup)" for?

Thanks
 
go well below you data and hit the End Key, then the Up Arrow key. It takes
you to the last cell containing data in that column. It is the same in
code. So I am finding the extent of your data in column A.
 

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