Invalid attribute in Sub, Function, or Property

Some attributes are invalid within procedures. This error has the following cause and solution:

  • A Public or Private attribute appears within the body of a procedure definition. Remove the attribute from the procedure. To give thevariable widerscope, move the declaration to module level. Variables declared within procedures are always Private.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).