The Top Ten Questions about VBA

I created a custom VBA function. When I try to use it in a formula, the formula displays #NAME?. What's wrong?

You probably have your function code in the wrong location. VBA code for worksheet functions must be in a standard VBA module — not in a module for a sheet or in ThisWorkbook.

Can I use the VBA macro recorder to record all of my macros?

No. Normally you use it only to record simple macros or as a starting point for a more complex macro. It cannot record macros that use variables, looping, or any other type of program flow constructs. In addition, you cannot record a Function procedure in the VBA macro recorder.

How can I prevent others from viewing my VBA code?

1. In the VBE, choose ToolsOVBA Project Properties.

2. In the dialog box, click the Protection tab and select Lock Project for Viewing.

3. Enter a password (twice) and click OK.

Doing so prevents casual users from viewing your code, but it is certainly not 100 percent secure. Password-cracking utilities exist.

0 0

Post a comment