Sunday, 27 September 2015

How to Call and Run a Macro from Another Workbook

How to Run a Macro from Another Workbook
When we want to run a Macro from an event or from another Macro in the same Workbook , We can call the Macro like this in code :

Call MyMacroName

But if we want to run a macro that is in another workbook or Add-In(File or add-in must be open).
We can use Application.Run as follows :

Application.Run "MyWorkBook.xls!MyMacroName"

Case I : Suppose if the Workbook name is not known in advance and its dynamically declared in a variable then we call the Macro as follows :

Application.Run " '" & strFileName & "'!MyMacroName"

Case II :Suppose if the Macro is specific to particular Worksheet Event , then we need to specify the Sheet name along with Macro name as follows :

Application.Run " '" & strFileName & "'!Sheet1.MyMacroName"

Please Note :
To get the Exact Macro name , we need to go to Macros in Excel Workbook where we can see all the Macros with Correct names to be use as reference for Calling/Running.


Saturday, 5 September 2015

SQL Update Query to Update a Table by Mapping with another Table

How to Do Mapping a Table with another Table with SQL Update Query
Suppose , we have a Table called 'Forecast_Table' , in which a column called 'Bus Entity' is need to update by Mapping it with a another Table called 'Map_Table' , then we can do it by using the Update query with Inner Join clause.

UPDATE Forecast_Table INNER JOIN Map_Table 
ON [Forecast_Table ].Tech=Map_Funnel.Tech 
SET Forecast_Table.[Bus Entity] = Map_Table.[Bus Entity];


Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts