Invalid attribute in Sub, Function, or Property

This page is specific to the Visual Basic for Applications (VBA) Language Reference for Office 2010.

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 the variable wider scope, 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).