ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sequentially run macros (https://www.excelbanter.com/excel-programming/350223-sequentially-run-macros.html)

CurtH

Sequentially run macros
 
I have several macros which in a module. I tried adding a Function state
with the various subs in between ended by a END Function. It doesn't work.
Does anyone have any suggestions? The code is like thus:

Option Explicit

Function Main_update()

Sub Update_IMR()
....Code...
End Sub
Sub Update_Profile
....Code...
End Sub
End Funtion

Please advise.


Andrew Taylor

Sequentially run macros
 
You can't nest Subs/Functions in the way you tried.
Just do this:

Option Explicit
Function Main_update() ' Sub might be more logical
Update_IMR
Update_Profile
' any other subs you want to run
End Function

Sub Update_IMR()
....Code...
End Sub

Sub Update_Profile
....Code...
End Sub




CurtH wrote:
I have several macros which in a module. I tried adding a Function state
with the various subs in between ended by a END Function. It doesn't work.
Does anyone have any suggestions? The code is like thus:

Option Explicit

Function Main_update()

Sub Update_IMR()
...Code...
End Sub
Sub Update_Profile
...Code...
End Sub
End Funtion

Please advise.



Bob Phillips[_6_]

Sequentially run macros
 
Function Main_update()
Update_IMR
Update_Profile
End Funtion


Sub Update_IMR()
....Code...
End Sub
Sub Update_Profile
....Code...
End Sub
--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CurtH" wrote in message
...
I have several macros which in a module. I tried adding a Function state
with the various subs in between ended by a END Function. It doesn't

work.
Does anyone have any suggestions? The code is like thus:

Option Explicit

Function Main_update()

Sub Update_IMR()
...Code...
End Sub
Sub Update_Profile
...Code...
End Sub
End Funtion

Please advise.




CurtH

Sequentially run macros
 
Thanks Andrew for the prompt response. I made the modifications you
instructed as follows:

Function Main_update()
Update_IMR
Update_Profile
Update_OverdueMIL
Update_Imm
Update_Dental
End Function

Sub Update_IMR()
....Code...
End Sub

Sub Update_Profile
.....Code...
End Sub

I then create function button to initate the code. Once I created the
button, I right click to assign the macro and it's not listed. Should I
cread sub calling the Main_Update?


"Andrew Taylor" wrote:

You can't nest Subs/Functions in the way you tried.
Just do this:

Option Explicit
Function Main_update() ' Sub might be more logical
Update_IMR
Update_Profile
' any other subs you want to run
End Function

Sub Update_IMR()
....Code...
End Sub

Sub Update_Profile
....Code...
End Sub




CurtH wrote:
I have several macros which in a module. I tried adding a Function state
with the various subs in between ended by a END Function. It doesn't work.
Does anyone have any suggestions? The code is like thus:

Option Explicit

Function Main_update()

Sub Update_IMR()
...Code...
End Sub
Sub Update_Profile
...Code...
End Sub
End Funtion

Please advise.




CurtH

Sequentially run macros
 
I see you left off the Option Explicit statement. Why? What's you take on
the above question?

"Bob Phillips" wrote:

Function Main_update()
Update_IMR
Update_Profile
End Funtion


Sub Update_IMR()
....Code...
End Sub
Sub Update_Profile
....Code...
End Sub
--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CurtH" wrote in message
...
I have several macros which in a module. I tried adding a Function state
with the various subs in between ended by a END Function. It doesn't

work.
Does anyone have any suggestions? The code is like thus:

Option Explicit

Function Main_update()

Sub Update_IMR()
...Code...
End Sub
Sub Update_Profile
...Code...
End Sub
End Funtion

Please advise.





Bob Phillips[_6_]

Sequentially run macros
 
I didn't leave it off on purpose. I am a firm advocate of Option Explicit, I
have it as a default option in my system.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CurtH" wrote in message
...
I see you left off the Option Explicit statement. Why? What's you take

on
the above question?

"Bob Phillips" wrote:

Function Main_update()
Update_IMR
Update_Profile
End Funtion


Sub Update_IMR()
....Code...
End Sub
Sub Update_Profile
....Code...
End Sub
--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CurtH" wrote in message
...
I have several macros which in a module. I tried adding a Function

state
with the various subs in between ended by a END Function. It doesn't

work.
Does anyone have any suggestions? The code is like thus:

Option Explicit

Function Main_update()

Sub Update_IMR()
...Code...
End Sub
Sub Update_Profile
...Code...
End Sub
End Funtion

Please advise.







Andrew Taylor

Sequentially run macros
 
It isn't listed in runnable macros because it's a Function. Change
to a Sub and it should be there

Andrew


CurtH wrote:
Thanks Andrew for the prompt response. I made the modifications you
instructed as follows:

Function Main_update()
Update_IMR
Update_Profile
Update_OverdueMIL
Update_Imm
Update_Dental
End Function

Sub Update_IMR()
....Code...
End Sub

Sub Update_Profile
....Code...
End Sub

I then create function button to initate the code. Once I created the
button, I right click to assign the macro and it's not listed. Should I
cread sub calling the Main_Update?


"Andrew Taylor" wrote:

You can't nest Subs/Functions in the way you tried.
Just do this:

Option Explicit
Function Main_update() ' Sub might be more logical
Update_IMR
Update_Profile
' any other subs you want to run
End Function

Sub Update_IMR()
....Code...
End Sub

Sub Update_Profile
....Code...
End Sub




CurtH wrote:
I have several macros which in a module. I tried adding a Function state
with the various subs in between ended by a END Function. It doesn't work.
Does anyone have any suggestions? The code is like thus:

Option Explicit

Function Main_update()

Sub Update_IMR()
...Code...
End Sub
Sub Update_Profile
...Code...
End Sub
End Funtion

Please advise.





CurtH

Sequentially run macros
 
Oh! Okay...Bob how can I assign this to my button? Do I create another sub
calling the Main_Update function?

"Bob Phillips" wrote:

I didn't leave it off on purpose. I am a firm advocate of Option Explicit, I
have it as a default option in my system.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CurtH" wrote in message
...
I see you left off the Option Explicit statement. Why? What's you take

on
the above question?

"Bob Phillips" wrote:

Function Main_update()
Update_IMR
Update_Profile
End Funtion


Sub Update_IMR()
....Code...
End Sub
Sub Update_Profile
....Code...
End Sub
--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CurtH" wrote in message
...
I have several macros which in a module. I tried adding a Function

state
with the various subs in between ended by a END Function. It doesn't
work.
Does anyone have any suggestions? The code is like thus:

Option Explicit

Function Main_update()

Sub Update_IMR()
...Code...
End Sub
Sub Update_Profile
...Code...
End Sub
End Funtion

Please advise.








Bob Phillips[_6_]

Sequentially run macros
 
No just change Main_Update from a function to a sub and assign that.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CurtH" wrote in message
...
Oh! Okay...Bob how can I assign this to my button? Do I create another

sub
calling the Main_Update function?

"Bob Phillips" wrote:

I didn't leave it off on purpose. I am a firm advocate of Option

Explicit, I
have it as a default option in my system.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CurtH" wrote in message
...
I see you left off the Option Explicit statement. Why? What's you

take
on
the above question?

"Bob Phillips" wrote:

Function Main_update()
Update_IMR
Update_Profile
End Funtion


Sub Update_IMR()
....Code...
End Sub
Sub Update_Profile
....Code...
End Sub
--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"CurtH" wrote in message
...
I have several macros which in a module. I tried adding a

Function
state
with the various subs in between ended by a END Function. It

doesn't
work.
Does anyone have any suggestions? The code is like thus:

Option Explicit

Function Main_update()

Sub Update_IMR()
...Code...
End Sub
Sub Update_Profile
...Code...
End Sub
End Funtion

Please advise.











All times are GMT +1. The time now is 09:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com