Running Macros from VBA

With Analytics Edge Core Add-in, you can run an Analytics Edge macro (e.g. “MyMacro”) from Visual Basic for Applications (VBA), using code similar to the following:

    Dim a As String
    a = Application.Run("AnalyticsEdge.RunMacro", "MyMacro")

Be careful of code conflicts between your VBA functionality and the Analytics Edge macro.

For example, if you wanted to trigger a refresh of the macro “Traffic Sources!$A$10″* when the value in cell A1 changed, you could write:

Private Sub Worksheet_Change(ByVal Target As Range)
  Dim a As String
  If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
    a = Application.Run("AnalyticsEdge.RunMacro", "Traffic Sources!$A$10")
  End If
End Sub

*this would be a default named macro created when the cell A10 was selected on the Traffic Sources worksheet.

Note that you can also run VBA macros from Analytics Edge macros as well:
See Using the Run Macro Function

New for v8.2: Now you can refresh all queries and macros simply by running a macro name of  “RefreshAll”!

Updated for v8.2.