VBA Question - Activate a Macro from another workbook or activate a hyperlink from another workbook - Excel 2010

Johnny Thunder

Well-known Member
Joined
Apr 9, 2010
Messages
693
Office Version
  1. 2016
Platform
  1. MacOS
Hello all,


What I am working on - I have a Master file that will open another workbook based on a list and the newly opened file will have a hyperlink on Cell ("C14") when you manually click the cell it Calls Macro1*. The problem I am having is in my research for this process I found this below

*Macro1 is a Addrows Macro
Code:
Application.Run ("'Analytics macro S17.xlsm'!getdata")

This won't work for me because I use a list Dimmed as a String to bring the File name and I wasn't able to make this work.

Here is my code so you can maybe see something I am not seeing.

Code:
  'Defines file name
   varCellvalue = Sheets("Main").Range("B23").Value

  'Defines Type of agreement and assigns Sheet to find
   varcell = Sheets("Main").Range("B19").Value
   

   'Defines newly opened Workbook
   Dim destbook As Workbook
 
       Workbooks.Open ("\\Lax-Netapp01\Dept_private\Business Systems\LFC MACRO TEST\" & varCellvalue & ".xlsm")
       Set destbook = ActiveWorkbook

   'Here is where I would enter something like 
     Application.Run (destbook & "!Macro1")


The other alternative is to activate a hyperlink from the newly opened workbook but I think calling the Macro1 is the more direct approach. Any help is always appreciated!

Thanks in advance for all who help.

</pre>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
The other alternative is to activate a hyperlink from the newly opened workbook but I think calling the Macro1 is the more direct approach. Any help is always appreciated!
I think you should record a macro from the master file... to see the default codes that it will generate.
 
Upvote 0
Not sure why I didn't think if that but it got the macro to run but in the macro I have a pop-up box that is "Dim as Integer" for a user to populate it with how many new rows you want added, when I was recording the macro and entered in a quantity the recorder didn't capture that function, any ideas on how to get that into the macro?
 
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,004
Members
449,480
Latest member
yesitisasport

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