The reason why your code doesn't work is to do with a thing called scope. Variables have a scope in the sense that they are created (Dim x as string), they are used (x = "hello world"), and then they are destroyed (x = nothing). VBA and most other languages imply scope at different levels, one of these levels is at the procedural level. Basically once the sub of function has finished running all variables locally defined in the sub or function are destroyed.
I'll use your sub to demonstrate
Dim fname 'here you create your variable fname
fname = InputBox(Enter your name" 'here you use your variable
End Sub 'once the sub completes all variables defines in the sub (fname) are destroyed
If you then wrote another sub to display the variable then you will have errors as the variable is out of scope, it has been destroyed.
Msgbox fname 'cannot use fname as it's out of scope
In this scenaro you would need to do this.... fname has a higher scope and is available to both the subprocedures.