answersLogoWhite

0

Are macros better than subroutines

User Avatar

Anonymous

10y ago
Updated: 8/18/2019

Generally no. When you have the choice, use a subroutine rather than a macro function, especially in strongly-typed languages. Macros are difficult to maintain, are not type safe, are always inline expanded (even when the inline optimiser is disabled) and the compiler cannot help you debug them. Subroutines have none of these problems.

Macros have their uses, especially in debug code where the code can be collapsed to a no-op in release builds. However, the onus is entirely upon the programmer to ensure the macros are used correctly.

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

How macro calls within macros are handled?

'=============>> Public Sub Main() 'Your code Call One 'your code End Sub '<<============= '=============>> Public Sub One() MsgBox "Hi from One" End Sub '<<============= > Does it matter where the other macros are stored or is it > better to have them all in one module? Unless there are a larger number of macros, they can be stored in a single module. However, for organisational reasons, it is usually better to store macros by type in different modules. Regards Rollick


What are the Advantages of using subroutines?

Subroutines can be used repeatedly without having to be rewritten each time they are used.


What are Submodules also known as?

subroutines


Why you use macros?

Macros are used to automate repetative tasks.


Why do you use macros?

Macros are used to automate repetative tasks.


How you run the macros into Microsoft Excel?

You can open the Macros section and run macros from there. The quickest way to do that is press Alt - F8. You can also run macros by clicking on buttons or other objects that you have assigned them to.


How do you get Macros to work on newer versions of Excel?

There can be many reasons why your macros are not working. Check security settings to ensure your version of Excel has macros enabled. Many times, the default installation disables the ability to use macros. Ensure you accept security certificates for the author of the macros.


What are the disadvantages of subroutines?

Subroutines can introduce additional overhead due to the need for context switching and passing parameters, potentially impacting performance, especially in time-sensitive applications. They may also complicate debugging and tracing, as errors can arise from interactions between various subroutines. Furthermore, excessive use of subroutines can lead to code that is harder to read and maintain, particularly if not well-documented. Lastly, if subroutines are poorly designed, they can create dependencies that make code less modular and reusable.


Why do need subroutines?

Subroutines, also known as functions or procedures, are essential in programming because they promote code reusability, organization, and readability. By breaking down complex tasks into smaller, manageable parts, subroutines allow developers to isolate functionality, making debugging and maintenance easier. They also enable collaboration, as different team members can work on separate subroutines without interfering with each other's code. Overall, subroutines enhance the efficiency and clarity of the coding process.


How do you run VB in Microsoft Excel?

You can do it by creating macros and then editing the macros. The macros or set of code can be applied to a button. It will depend on the version of Excel you have, but you can usually start creating macros or writing code through the Tools menu.


Do word processor support macros?

Some word processor support macros, some does not.


Can we add two subroutines in VBA macro?

Yes.