Skip to content

Latest commit

 

History

History
54 lines (32 loc) · 1.92 KB

Excel.Application.ExecuteExcel4Macro.md

File metadata and controls

54 lines (32 loc) · 1.92 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Application.ExecuteExcel4Macro method (Excel)
vbaxl10.chm132097
vbaxl10.chm132097
Excel.Application.ExecuteExcel4Macro
0afa77ab-43e0-0120-4ffd-25e290c72f6c
04/04/2019
medium

Application.ExecuteExcel4Macro method (Excel)

Runs a Microsoft Excel 4.0 macro function and then returns the result of the function. The return type depends on the function.

Syntax

expression.ExecuteExcel4Macro (String)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
String Required String A Microsoft Excel 4.0 macro language function without the equal sign. All references must be given as R1C1 strings. If String contains embedded double quotation marks, you must double them.

For example, to run the macro function =MID("sometext",1,4), String would have to be "MID(""sometext"",1,4)".

Return value

Variant

Remarks

The Microsoft Excel 4.0 macro isn't evaluated in the context of the current workbook or sheet. This means that any references should be external and should specify an explicit workbook name. For example, to run the Microsoft Excel 4.0 macro "My_Macro" in Book1 you must use "Book1!My_Macro()". If you don't specify the workbook name, this method fails.

Example

This example runs the GET.CELL(42) macro function on cell C3 on Sheet1 and then displays the result in a message box. The GET.CELL(42) macro function returns the horizontal distance from the left edge of the active window to the left edge of the active cell. This macro function has no direct Visual Basic equivalent.

Worksheets("Sheet1").Activate 
Range("C3").Select 
MsgBox ExecuteExcel4Macro("GET.CELL(42)")

[!includeSupport and feedback]