Editing a macro which is within another macro.

T

Tom

When I am running macro1, how can I call on macro2 to edit it in order
to replace all instances of "abc" with "xyz" before continuing on and
execute macro2? Thanks for your help.

Tom
 
R

Robert Martim, Excel

Tom

If xyz is a variable you might just change its value to something else while
calling the second macro. For example:

Sub Macro1()
Dim abc As String
abc = "Hello world!"
Call Macro2(abc)
End Sub

Sub Macro2(ByVal xyz As String)
MsgBox xyz
End Sub

--
Best regards
Robert, Excel MVP
Author of RibbonX: Customizing the Office 2007 Ribbon:
Find me at http://www.msofficegurus.com - be part of it!
FORUM: http://www.msofficegurus.com/forum/
 
T

Tom

Tom

If xyz is a variable you might just change its value to something else while
calling the secondmacro. For example:

Sub Macro1()
  Dim abc   As String
  abc = "Hello world!"
  Call Macro2(abc)
End Sub

Sub Macro2(ByVal xyz As String)
  MsgBox xyz
End Sub

--
Best regards
Robert, Excel MVP
  Author of RibbonX: Customizing the Office 2007 Ribbon:
  Find me athttp://www.msofficegurus.com- be part of it!
  FORUM:http://www.msofficegurus.com/forum/

Thanks Robert. That was great.

Regards,
Tom
 
T

Tom

Tom

If xyz is a variable you might just change its value to something else while
calling the second macro. For example:

Sub Macro1()
  Dim abc   As String
  abc = "Hello world!"
  Call Macro2(abc)
End Sub

Sub Macro2(ByVal xyz As String)
  MsgBox xyz
End Sub

--
Best regards
Robert, Excel MVP
  Author of RibbonX: Customizing the Office 2007 Ribbon:
  Find me athttp://www.msofficegurus.com- be part of it!
  FORUM:http://www.msofficegurus.com/forum/

However, there was a snag. I should have made it clearer.
Macro1 resides in File1.xls while Macro2 resides in File2.xls
and "abc" and "xyz" are both strings in Macro2. So, what do I
have to modify? Thanks.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top