spencer_time
Board Regular
- Joined
- Sep 19, 2019
- Messages
- 55
- Office Version
- 365
- 2016
- 2007
- Platform
- Windows
Hello again guys, I'm still trying to learn VBA and excel macros as best and fast as I can and one of the ways I have been doing that is posting my problems for you guys to help me with AND looking at others posts and attempting to help them with their problems.
I was trying to help someone and noticed the flag ByVal in front of a variable in a function and didn't know what it was.
Some quick google searching revealed that ByRef is the default and excel uses the argument as a reference, ByVal can be used instead to force excel to use the argument as a value instead.
I have experimented with both of them trying to understand the difference in a practical sense and I can't notice anything change.....
What I am asking is what is the difference between ByRef and ByVal and when would you want to use ByVal?
Thanks in advance for your time and help.
I was trying to help someone and noticed the flag ByVal in front of a variable in a function and didn't know what it was.
Some quick google searching revealed that ByRef is the default and excel uses the argument as a reference, ByVal can be used instead to force excel to use the argument as a value instead.
I have experimented with both of them trying to understand the difference in a practical sense and I can't notice anything change.....
What I am asking is what is the difference between ByRef and ByVal and when would you want to use ByVal?
Thanks in advance for your time and help.