Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Insert variable cell in the formula

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Insert variable cell in the formula

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"

--

Regards,
Tom Ogilvy

"Gian" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Insert variable cell in the formula

Thanks Tom.

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

"Tom Ogilvy" wrote:

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"

--

Regards,
Tom Ogilvy

"Gian" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Insert variable cell in the formula

"=" & 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.

--
Regards,
Tom Ogilvy



"Gian" wrote in message
...
Thanks Tom.

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

"Tom Ogilvy" wrote:

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"

--

Regards,
Tom Ogilvy

"Gian" wrote in message
...
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






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Insert variable cell in the formula


Hi Tom,

This is exactly what I want. Appreciate your help.

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

Thanks


"Tom Ogilvy" wrote:

"=" & 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.

--
Regards,
Tom Ogilvy



"Gian" wrote in message
...
Thanks Tom.

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

"Tom Ogilvy" wrote:

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"

--

Regards,
Tom Ogilvy

"Gian" wrote in message
...
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








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Insert variable cell in the formula

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.

--
Regards,
Tom Ogilvy

"Gian" wrote in message
...

Hi Tom,

This is exactly what I want. Appreciate your help.

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

Thanks


"Tom Ogilvy" wrote:

"=" & 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.

--
Regards,
Tom Ogilvy



"Gian" wrote in message
...
Thanks Tom.

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

"Tom Ogilvy" wrote:

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"

--

Regards,
Tom Ogilvy

"Gian" wrote in message
...
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








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert contents of variable cell address Charlie@ParkViewTerrace Excel Discussion (Misc queries) 1 June 30th 09 11:28 PM
how do I insert a variable amount of blank spaces in a formula? Lucy4484 Excel Worksheet Functions 1 January 14th 07 10:36 PM
insert a variable into a formula pappy Excel Discussion (Misc queries) 1 August 4th 06 01:45 PM
Can one insert a variable/cell ref. in the heading mykmag Excel Discussion (Misc queries) 7 May 16th 05 02:42 PM
How can I insert a cell reference in a footer (eg for variable foo wngg001 Excel Discussion (Misc queries) 1 December 15th 04 10:56 AM


All times are GMT +1. The time now is 02:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"