Error Environ | Username

joshcas

New Member
Joined
Jan 25, 2012
Messages
32
HI,
I’m working to set the value of a variable to “Environ(“Username”)” but I’m getting an error about “Constant expression required” , not sure what I’m doing wrong
Code:
Const computeruser = Environ("USERNAME")
Any help will be much appreciated
josh
 

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,168
You are setting the value of a constant and not a variable.

This is from the Const help.
"You can't use variables, user-defined functions, or intrinsic Visual Basic functions (such as Chr) in expressions assigned to constants."

Environ is an intrinsic VBA function.
 

Forum statistics

Threads
1,082,478
Messages
5,365,784
Members
400,850
Latest member
Raj_Jpr

Some videos you may like

This Week's Hot Topics

Top