By declaring a constant, you can assign a meaningful name to a value. You use the Const statement to declare a constant and set its value. After a constant is declared, it cannot be modified or assigned a new value.
It is my understanding that all constants are replaced by their values before the code is physically compiled into executable form. In essence, this part of the process acts like a word processor modifying a text file by replacing small pieces of text with other small pieces of text to produce a modified text file (the "final" code)... only then is the code (text file) compiled into executable form.
VBA says that Range("B22").Value is not constant, not because the value in the cell can change, but because Range is a function, not a constant.
Similarly Const myVal As String = UCase("cat") would get the same error.
A work-around (that requires no change in the other coding) would be to cast strFileName as a function
Public Function strFileName() as String
strFileName = Range("B22").Value
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.