Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a Macro code which starts with Sub Macroname........and in that code I am also having a Function FunctionNmae.......
when I try to run that macro.....should I use two names...I mean should I have to give triggers to run macro on both SUB and Function........
A function executes code and returns a result, a sub only executes code but doesn't return a result. You should use subs for macros. Subs can call functions (and other subs). Try adding the code below in the macro editor and click the Test button.
Function TimesTwo(X)
TimesTwo = X+X
end function
Sub Add
result = TimesTwo(3)
msgbox result
end Sub
A function executes code and returns a result, a sub only executes code but doesn't return a result. You should use subs for macros. Subs can call functions (and other subs). Try adding the code below in the macro editor and click the Test button.
Function TimesTwo(X)
TimesTwo = X+X
end function
Sub Add
result = TimesTwo(3)
msgbox result
end Sub
Thankyou.....So if I have one Sub and two functions I need to run macro and give sub name and should not worry about the functions......
Yes, don't worry about the functions. Just use the subs for the run-macro actions
Thankyou Gysbert....I am still trying to send report after reload as email trough macro....I am not finding exact code.......I went trough community but did not find one........Can you Please help me out........