Consecutive Auto Run

mysterious-dr-x

Board Regular
Joined
Jul 29, 2011
Messages
51
So I have 3 macros, ImportData, RemoveDuplicates & Sort (all of which I feel are rather self explanatory)

I know this method of autorun for just the 1st....

Code:
Private Sub Workbook_Open()
    Call ImportData
End Sub
....but how do I do all 3 consecutively?


EDIT: The following seems to work, is this acceptable practice?

Code:
Private Sub Workbook_Open()
    Call ImportData
    Call RemoveDuplicates
    Call Sort
End Sub
 
Last edited:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
My suggestion if you would like to run all three macros then call the next macro inside your first one and the third one in your second...
 
Upvote 0
...
EDIT: The following seems to work, is this acceptable practice?

Code:
Private Sub Workbook_Open()
    Call ImportData
    Call RemoveDuplicates
    Call Sort
End Sub

That is fine. I would humbly suggest changing the name of the last one. Not that it won't work, but naming stuff after things that exist natively, in this case a Method, can be confusing later.

Hope that helps,

Mark
 
Upvote 0
My suggestion if you would like to run all three macros then call the next macro inside your first one and the third one in your second...
Personally I wouldn't 'chain' a subroutine in that way unless I needed to execute some additional code after control had returned from the subroutine.

If the routines can genuinely be run independently, I would prefer to call them in turn from a 'driver' macro where it's obvious that they are independent from each other. One look at the driver routine and you know immediately what the relationship between the various subroutines is.

But that's just me! :)
 
Upvote 0
If the routines can genuinely be run independently, I would prefer to call them in turn from a 'driver' macro where it's obvious that they are independent from each other. One look at the driver routine and you know immediately what the relationship between the various subroutines is.

But that's just me! :)

How would you go about doing that?
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

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