Stepping through VB code

P

paul.domaskis

I'm getting the trial by fire in VB code by working someone else's
macros. No VB training, but enough C++ training that it make sense.
I can't find any help on stepping through code during execution
(statement by statement). A search for stepping just turns up hits on
step-by-step tutorials. Unfortunately, I won't be able to learn it
from the ground up, so I wonder if someone could point to a website
that dives right into stepping through code for debugging.

Thanks.
 
G

Gord Dibben

With a workbook containing macros open..............

Alt + F11 to open VB Editor.

CTRL + r to open Project Explorer.

Expand your workbook/project.

Double-click on a Module to open the Module in your Project.

Select anywhere within a macro and then on Menu hit "Debug" and "Step into"

F8 to step through.


Gord Dibben MS Excel MVP
 
P

paul.domaskis

I must be blind. Thanks for pointing out the Debug pull-down menu.

By the way, I'm finding that VBA doesn't just take cell expressions.
After some searching,

http://en.allexperts.com/q/Visual-Basic-1048/Entering-formula-Excel-VB.htm

reveals that you have to use the object representing the instance of
Excel, invoke a member function Evaluate, then supply the expression
to evaluate.

How does one find the variable name for the object representing the
running instance of Excel?

Is there a website that focuses exclusively on syntax/idiom knowledge
in making VBA work in Excel?
 
R

Rick Rothstein

The only reason there is a reference to the object representing the instance
of Excel is because you are looking at code meant for the compiled version
of VB6 (which has to create an instance of Excel in order to work with it) ,
not the VB6 version built into Excel. The object you would use inside of
Excel's VB world to reference the running version of Excel is the
Application object; for example...

Application.Evaluate ....

--
Rick (MVP - Excel)


I must be blind. Thanks for pointing out the Debug pull-down menu.

By the way, I'm finding that VBA doesn't just take cell expressions.
After some searching,

http://en.allexperts.com/q/Visual-Basic-1048/Entering-formula-Excel-VB.htm

reveals that you have to use the object representing the instance of
Excel, invoke a member function Evaluate, then supply the expression
to evaluate.

How does one find the variable name for the object representing the
running instance of Excel?

Is there a website that focuses exclusively on syntax/idiom knowledge
in making VBA work in Excel?
 

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

Top