Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default how to use VBA variable in formula?

I sincerely appreciate whoever's help on this question!

I need to use Excel formula functions of COUNTIF and SUM in VBA. The range
for calculation need to refer to a variable set in the VBA which is changing
from one worksheet to another. However, the variable can't be recognized by
the COUNTIF function. The actual statement is:
Selection.Value = "=COUNTIF(RC[1 - C]:RC[- 1], ""Abs"")"
or
Activecell.FormulaR1C1 = "=COUNTIF(RC[1 - C]:RC[- 1], ""Abs"")"
"C" is the variable set in VBA that has to be used for iteration steps in
diferrent worksheet.
How to make Excel function work by using the variable "C"?

  #2   Report Post  
Posted to microsoft.public.excel.programming
zz zz is offline
external usenet poster
 
Posts: 32
Default how to use VBA variable in formula?

i use a trick, i save the value of the variable in cell A6000 and name it
[the cell] the same as the variable, then reference this cell in my formula.


--
---
zz [MX]
cuasi-musico,semi-poeta y loco



"Terry" wrote in message
...
I sincerely appreciate whoever's help on this question!

I need to use Excel formula functions of COUNTIF and SUM in VBA. The range
for calculation need to refer to a variable set in the VBA which is
changing
from one worksheet to another. However, the variable can't be recognized
by
the COUNTIF function. The actual statement is:
Selection.Value = "=COUNTIF(RC[1 - C]:RC[- 1], ""Abs"")"
or
Activecell.FormulaR1C1 = "=COUNTIF(RC[1 - C]:RC[- 1], ""Abs"")"
"C" is the variable set in VBA that has to be used for iteration steps in
diferrent worksheet.
How to make Excel function work by using the variable "C"?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default how to use VBA variable in formula?

Thank you very much!
But the variable "C" is used to define one end of the range. if replaced by
another range name, the COUNTIF function still can't recognize it.

This function is aiming to count how many "ABC" within the left side (C-1)
columns of the activecell. "C" is changing in different worksheets and
activecell is is changing within one worksheet column. And, I must write it
within VBA instead of worksheet because of the number of activecell need to
get teh result is uncertain.

Activecell.FormulaR1C1 = "=COUNTIF(RC[1 - C]:RC[- 1], ""Abs"")"

"zz" wrote:

i use a trick, i save the value of the variable in cell A6000 and name it
[the cell] the same as the variable, then reference this cell in my formula.


--
---
zz [MX]
cuasi-musico,semi-poeta y loco



"Terry" wrote in message
...
I sincerely appreciate whoever's help on this question!

I need to use Excel formula functions of COUNTIF and SUM in VBA. The range
for calculation need to refer to a variable set in the VBA which is
changing
from one worksheet to another. However, the variable can't be recognized
by
the COUNTIF function. The actual statement is:
Selection.Value = "=COUNTIF(RC[1 - C]:RC[- 1], ""Abs"")"
or
Activecell.FormulaR1C1 = "=COUNTIF(RC[1 - C]:RC[- 1], ""Abs"")"
"C" is the variable set in VBA that has to be used for iteration steps in
diferrent worksheet.
How to make Excel function work by using the variable "C"?




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
Variable VBA Max Formula Gizmo Excel Discussion (Misc queries) 2 June 6th 08 06:12 AM
formula containing a formula-dependent variable - how? CompeterN New Users to Excel 1 November 8th 06 02:02 PM
Variable in formula StephanieH Excel Programming 2 January 12th 06 03:10 PM
Using a variable in a VBA formula Colin Vicary Excel Discussion (Misc queries) 3 November 8th 05 11:39 AM
Using a variable in a formula Noah Excel Programming 3 October 28th 05 04:39 PM


All times are GMT +1. The time now is 05:35 PM.

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"