PDA

View Full Version : Solved: Calling a Subroutine



bopo
05-21-2007, 04:11 PM
Hi

Yet another question, basically lets say I have several exit buttons throughout my program, I create a little sub in a module which contains the coding.

Now could I have a small piece of coding which would link to the sub within the Module and execute it?

Thanks

lucas
05-21-2007, 04:29 PM
Sub a()
name of the little sub in a module which contains the coding(one word)
end sub

Cyberdude
05-21-2007, 05:03 PM
Yep, except I might suggest you use "CALL subname" to remind you that it's a macro and not a variable. It helps the self documentation objective.
Sid

bopo
05-21-2007, 05:34 PM
Hi

That works for form based buttons, however i was wondering if something can be used for buttons on UserForms?



Sub a()
name of the little sub in a module which contains the coding(one word)
end sub

lucas
05-21-2007, 05:37 PM
hi bobo...pretty basic stuff here...read your help files some ok?
Private Sub CommandButton1_Click()
name of the little Sub In a module which contains the coding(one word)
End Sub
Sid is right too...probably a good idea to use call then the name of the macro

geekgirlau
05-21-2007, 05:38 PM
In that case, the name of the sub-routine you're calling might be something like:


cmdImport_Click

lucas
05-21-2007, 05:40 PM
click is the key...Hi Anne :hi:

geekgirlau
05-21-2007, 06:22 PM
Hiya Steve!