How to efficiently declare variables

G

Guest

I guess I don't understand how to correctly declare variables. Before I had
been writing

Dim x1, x2, x3, x4 as double

I just learned that this declares x1, x2, and x3 as variants and x4 as a
double. Is there an easier way to declare x1, x2, x3 and x4 as double other
then typing

x1 as double, x2 as double, etc.

This seems like a HUGE pain because I have about 75 variables in my module.
(These are declared at the modular level, so they can be used by all the
macros in the module)

Thanks for your help.
 
A

Andrew Taylor

You could maybe use DefDbl :

DefDbl X

This means that any variable whose name begins with
an X (or x) is automatically a double, unless it's declared
otherwise.

See Excel Help for more details..

Andrew
 
B

Bob Phillips

Nope, that is what you are stuck with.

But honestly, how big a pain is it? As soon as you type D intelliesense
gives you a list of values, o a shorter list, and u, Double is at the top.

75 variables is nothing, I have hundreds of constants I declare as

Public Const COL_NAME As Long = 17

etc.

but I only do it once.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

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