Supercharge Your Vba Skills With Subroutines And Functions! | Summary and Q&A

TL;DR
This video explains the difference between subroutines and functions in Excel macros, as well as the usage of public and private variables.
Key Insights
- đ¨âđģ The coding window in Excel macros is where you write VBA code.
- âŠī¸ Subroutines are used to execute code without returning a value, while functions can return a value.
- đ Public variables can be accessed by multiple subroutines, while private variables are limited to a specific subroutine.
- đ It is best practice to use subroutines over functions in Excel macros.
- đĒ Subroutines and functions can be added in modules or sheets.
- đ When defining variables, choosing between public or private determines their scope of usage.
- đģ Using public variables allows sharing data across multiple subroutines.
Transcript
Read and summarize the transcript of this video on Glasp Reader (beta).
Questions & Answers
Q: What is the difference between subroutines and functions in Excel macros?
Subroutines do not return any value and are used to execute code, while functions can return a value.
Q: How do you add a subroutine in Excel macros?
To add a subroutine, you need to open the coding window and use the syntax "Sub [subroutine name]". Code written inside the subroutine will be executed.
Q: Can functions be used instead of subroutines in Excel macros?
Yes, functions can be used, but subroutines are preferred. The hierarchy in Java is different, where functions are commonly used, but in Excel macros, we prefer subroutines.
Q: What is the difference between public and private variables in Excel macros?
Public variables can be accessed by multiple subroutines, while private variables are limited to the subroutine in which they are defined.
Summary & Key Takeaways
-
The video introduces the coding window in Excel macros and explains the need for subroutines and functions.
-
Subroutines are used to execute code and do not return any value, while functions can return a value.
-
Public variables can be accessed by multiple subroutines, while private variables are limited to a specific subroutine.
Share This Summary đ
Explore More Summaries from Ekeeda đ





