ways to call "sub" routines

MetLife

Active Member
Joined
Jul 2, 2012
Messages
327
Office Version
  1. 365
Hi,

I am analyzing someone else's code. One thing I notice is that they alternate between

run("some_macro")

and

call some_macro

Why is there a difference in the way the macro is called & does this make any difference?

I personally don't like changing the way it is called, I would prefer just using the "Call" command or "run" but alternating is confusing to me.

Thanks
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Unless you have a specific reason to use Run (eg you are calling a routine in another workbook) I would always recommend using a direct call to the routine - although actually using the Call keyword is unnecessary.
 
Upvote 0
I always use:

Call Bob
Or
Call Me

It helps me remember what's happening here in this line of code.

If I just see

Bob

I think what is Bob
 
Upvote 0
I think the exact same thing. For me it is better if we are limited to just using "Call Bob" etc...

I also think it is better if the vba will automatically color code variables/functions automatically. This also helps clear things up. I wonder why this isn't implemented?
 
Upvote 0
You can change the formatting of most things in the VBE using the colour options.

If you were limited to Call, you wouldn't be able to run code in other projects without setting references, nor could you build up routine names at runtime. It is entirely up to you what practices you adopt. Limiting the language further would not, in my opinion, be an improvement.
 
Last edited:
Upvote 0
I see in "tools-> options-> Editor Format" they have the options to change color for comments and errors. I don't see the variables or sub routines though.
 
Upvote 0
"Identifier text" is the one you want.
 
Upvote 0
RoyA

If there is a easy way to color some lines of code quickly
Would you please explain more about how to do that.

Do we always have to select line of code and then go into Tools and Text identifier. Etc.
 
Upvote 0
No, there isn't. Why would you want to colour entire lines of code?
 
Upvote 0
I thought that was what you were saying when you said:
You can change the formatting of most things in the VBE using the colour options.
I thought you were saying we could color something like Call Bob. So it would stand out from the other code.


No, there isn't. Why would you want to colour entire lines of code?
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,985
Members
452,540
Latest member
haasro02

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top