ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Link Macros Excel 2007 (https://www.excelbanter.com/excel-discussion-misc-queries/176623-link-macros-excel-2007-a.html)

JohnH

Link Macros Excel 2007
 
I recorded a macro (very large copy from one sheet and paste into another
sheet). It works fine. I then made some edits to it so that it would be more
generic abd reusable. This caused it to be to big to compile so I have to
slice it up into multiple marros.Both still work fine. How do I link the
maros so after macro1 finishes, marcor2 will start or is that just going to
introduce the file size problem again?

Do comments count in compield file size? I extensively commented the maro so
I could find my way around when debugging.

Thanks - John

Conan Kelly

Link Macros Excel 2007
 
JohnH,

Are both of these macros in the same module?

I have no experience with XL 2007, but VBA in XL 2007 & XL 2003 should be
almost identical.

In order to start the 2nd macro after the 1st one has run, just call the 2nd
one from the 1st one. In the very last line of the 1st macro (between your
last line of code and "End Sub"), put the name of the second macro.

Keep in mind, I've never run into "to big to compile" errors, so I don't
know if doing things this way will cause the same problems you were having
before.

HTH,

Conan




"JohnH" wrote in message
...
I recorded a macro (very large copy from one sheet and paste into another
sheet). It works fine. I then made some edits to it so that it would be
more
generic abd reusable. This caused it to be to big to compile so I have to
slice it up into multiple marros.Both still work fine. How do I link the
maros so after macro1 finishes, marcor2 will start or is that just going
to
introduce the file size problem again?

Do comments count in compield file size? I extensively commented the maro
so
I could find my way around when debugging.

Thanks - John




JohnH

Link Macros Excel 2007
 
Thanks Conan

I really don't know my way around Macros/VB. I understand what you said but
don't know the details.

All my macros for this project are in the same worksheet.

When opening Macro1 in edit mode at the end there is a dividing line and
Macro2 starts. It appears the both macros are part of the same file? I did
not intentionally set it up that way. I suspect functions as designed? When
I run Macro1 it stops. at the End Sub line. It does not auto run Macro2 which
starts immedatley after the dividing line. I tried pasting Sub Macro2() above
End SUb in Macro1 but that causes a compile error until I remove it. If I
paste all the Macro2 code into Marco1 I get the too big compile error when I
run it.

What is the syntax for adding the call to macro2 in macro1?

Thanks
John


"Conan Kelly" wrote:

JohnH,

Are both of these macros in the same module?

I have no experience with XL 2007, but VBA in XL 2007 & XL 2003 should be
almost identical.

In order to start the 2nd macro after the 1st one has run, just call the 2nd
one from the 1st one. In the very last line of the 1st macro (between your
last line of code and "End Sub"), put the name of the second macro.

Keep in mind, I've never run into "to big to compile" errors, so I don't
know if doing things this way will cause the same problems you were having
before.

HTH,

Conan




"JohnH" wrote in message
...
I recorded a macro (very large copy from one sheet and paste into another
sheet). It works fine. I then made some edits to it so that it would be
more
generic abd reusable. This caused it to be to big to compile so I have to
slice it up into multiple marros.Both still work fine. How do I link the
maros so after macro1 finishes, marcor2 will start or is that just going
to
introduce the file size problem again?

Do comments count in compield file size? I extensively commented the maro
so
I could find my way around when debugging.

Thanks - John





Conan Kelly

Link Macros Excel 2007
 
JohnH,

From the sounds of it, you have your macros in one module.

Your macros are probably in the form of:



Sub Macro1()
'1st line of code
'2nd line of code
...
...
...
'Last line of code
End Sub

-------------------------

Sub Macro2()
'1st line of code
'2nd line of code
...
...
...
'Last line of code
End Sub



Change your code to the following:



Sub Macro1()
'1st line of code
'2nd line of code
...
...
...
'Last line of code
Macro2
End Sub

-------------------------

Sub Macro2()
'1st line of code
'2nd line of code
...
...
...
'Last line of code
End Sub



Notice, I put the call to Macro2 (just put the macro's name) within Macro1,
just after the last line of code.

HTH,

Conan






"JohnH" wrote in message
...
Thanks Conan

I really don't know my way around Macros/VB. I understand what you said
but
don't know the details.

All my macros for this project are in the same worksheet.

When opening Macro1 in edit mode at the end there is a dividing line and
Macro2 starts. It appears the both macros are part of the same file? I did
not intentionally set it up that way. I suspect functions as designed?
When
I run Macro1 it stops. at the End Sub line. It does not auto run Macro2
which
starts immedatley after the dividing line. I tried pasting Sub Macro2()
above
End SUb in Macro1 but that causes a compile error until I remove it. If I
paste all the Macro2 code into Marco1 I get the too big compile error when
I
run it.

What is the syntax for adding the call to macro2 in macro1?

Thanks
John


"Conan Kelly" wrote:

JohnH,

Are both of these macros in the same module?

I have no experience with XL 2007, but VBA in XL 2007 & XL 2003 should be
almost identical.

In order to start the 2nd macro after the 1st one has run, just call the
2nd
one from the 1st one. In the very last line of the 1st macro (between
your
last line of code and "End Sub"), put the name of the second macro.

Keep in mind, I've never run into "to big to compile" errors, so I don't
know if doing things this way will cause the same problems you were
having
before.

HTH,

Conan




"JohnH" wrote in message
...
I recorded a macro (very large copy from one sheet and paste into
another
sheet). It works fine. I then made some edits to it so that it would be
more
generic abd reusable. This caused it to be to big to compile so I have
to
slice it up into multiple marros.Both still work fine. How do I link
the
maros so after macro1 finishes, marcor2 will start or is that just
going
to
introduce the file size problem again?

Do comments count in compield file size? I extensively commented the
maro
so
I could find my way around when debugging.

Thanks - John







JohnH

Link Macros Excel 2007
 
Thanks Much Conan- It works great and no more too large to compile errors.

Thanks
John

"Conan Kelly" wrote:

JohnH,

From the sounds of it, you have your macros in one module.

Your macros are probably in the form of:



Sub Macro1()
'1st line of code
'2nd line of code
...
...
...
'Last line of code
End Sub

-------------------------

Sub Macro2()
'1st line of code
'2nd line of code
...
...
...
'Last line of code
End Sub



Change your code to the following:



Sub Macro1()
'1st line of code
'2nd line of code
...
...
...
'Last line of code
Macro2
End Sub

-------------------------

Sub Macro2()
'1st line of code
'2nd line of code
...
...
...
'Last line of code
End Sub



Notice, I put the call to Macro2 (just put the macro's name) within Macro1,
just after the last line of code.

HTH,

Conan






"JohnH" wrote in message
...
Thanks Conan

I really don't know my way around Macros/VB. I understand what you said
but
don't know the details.

All my macros for this project are in the same worksheet.

When opening Macro1 in edit mode at the end there is a dividing line and
Macro2 starts. It appears the both macros are part of the same file? I did
not intentionally set it up that way. I suspect functions as designed?
When
I run Macro1 it stops. at the End Sub line. It does not auto run Macro2
which
starts immedatley after the dividing line. I tried pasting Sub Macro2()
above
End SUb in Macro1 but that causes a compile error until I remove it. If I
paste all the Macro2 code into Marco1 I get the too big compile error when
I
run it.

What is the syntax for adding the call to macro2 in macro1?

Thanks
John


"Conan Kelly" wrote:

JohnH,

Are both of these macros in the same module?

I have no experience with XL 2007, but VBA in XL 2007 & XL 2003 should be
almost identical.

In order to start the 2nd macro after the 1st one has run, just call the
2nd
one from the 1st one. In the very last line of the 1st macro (between
your
last line of code and "End Sub"), put the name of the second macro.

Keep in mind, I've never run into "to big to compile" errors, so I don't
know if doing things this way will cause the same problems you were
having
before.

HTH,

Conan




"JohnH" wrote in message
...
I recorded a macro (very large copy from one sheet and paste into
another
sheet). It works fine. I then made some edits to it so that it would be
more
generic abd reusable. This caused it to be to big to compile so I have
to
slice it up into multiple marros.Both still work fine. How do I link
the
maros so after macro1 finishes, marcor2 will start or is that just
going
to
introduce the file size problem again?

Do comments count in compield file size? I extensively commented the
maro
so
I could find my way around when debugging.

Thanks - John








All times are GMT +1. The time now is 05:40 PM.

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