Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Gracie Hughes   on Mar 04 In MS Office Category.

  
Question Answered By: Mercedes Andrews   on Mar 04

My point was, if you are using VBA merely to read the result
of a formula, perhaps there is a way to recode the routine to do the
calculation exclusively in VBA, to reduce the unnecessary back and
forth between the worksheet  and the object model. That would be
"taking advantage of the built-in functions  of Excel (and VBA)".

My comments were directed towards those interested in
improving their VBA routines (and formula writing) in terms of
efficiency.

In my experience, there are many ways to write formulas  and
code, but some are much better (relatively speaking) than others. The
most popular example I can think of is using VBA to loop through a
range of cells. Oftentimes there are ways to rewrite a routine to
take advantage of built-in functions (the Find, SpecialCells, etc I
mentioned earlier) that will result in speed gains of orders of
magnitude. In other words, all ways are not roughly equivalent, and
there are clear advantages to using one process over another.
Trying to find the most efficient way to complete a task will lead to
benefits in your own programming in the long  term.

It has nothing to do with right or wrong; it's all in terms
of speed and efficiency.

If your way leads to correct results, there is nothing wrong
with that. In absolute terms, you probably won't see (or notice) much
benefit in re-factoring.

Share: 

 

This Question has 26 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Worksheet functions in VBA Or get search suggestion and latest updates.


Tagged: