EXCEL functions within VBA code

  • Thread starter Thread starter RealInfo
  • Start date Start date
Of course it is okay, as long as you know what you are doing, why you are
doing it, and don't overdo it.

The link that Harald provided to the MSDN site gives lots of information of
the pros and cons.
 
Hi

Assuming you are just asking "can" you do this, the answer is yes. Many
ways, but we need to know what it is you are doing to be more helpful.

Here are three examples

ActiveCell = "=SUMIF(R[-11]C[-2]:R[-2]C[-2],2,R[-11]C:R[-2]C)"
ActiveCell = "=SUMIF(A12:A21,2,C12:C21)"
x = WorksheetFunction.SumIf(Range("A12:A21"), 2, Range("C12:C21"))

The first two put the sumif function into the activecell the third one
stores the result of a sumif calculation in a variable.
 
Thanks
ec


Shane Devenshire said:
Hi

Assuming you are just asking "can" you do this, the answer is yes. Many
ways, but we need to know what it is you are doing to be more helpful.

Here are three examples

ActiveCell = "=SUMIF(R[-11]C[-2]:R[-2]C[-2],2,R[-11]C:R[-2]C)"
ActiveCell = "=SUMIF(A12:A21,2,C12:C21)"
x = WorksheetFunction.SumIf(Range("A12:A21"), 2, Range("C12:C21"))

The first two put the sumif function into the activecell the third one
stores the result of a sumif calculation in a variable.
--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


RealInfo said:
Hi all

Is it OK to include excell functions into VBA code ?

Thanks
EC
 

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