strFileName = Range("B22").Value
Const myVal As String = UCase("cat")
would get the same error.Public Function strFileName() as String
strFileName = Range("B22").Value
End Function
According to Wikipedia (Visual Basic for Applications - Wikipedia)... "Code written in VBA is compiled to Microsoft P-Code (pseudo-code), a proprietary intermediate language, which the host applications (Access, Excel, Word, Outlook, and PowerPoint) store as a separate stream in COM Structured Storage files (e.g., .doc or .xls) independent of the document streams. The intermediate code is then executed by a virtual machine (hosted by the host application)." It is during the compiling into P-Code that I believe the constant names are replaced by their values (text replacing text)... it's during execution by the hosted virtual machine where I believe the line-by-line interpretation takes place.Rick
That may be the case for languages that are compiled but VBA is interpreted.