Skip to content

Instantly share code, notes, and snippets.

@Zadigo
Last active October 25, 2017 18:15
Show Gist options
  • Save Zadigo/0aa7fc579b4256b508eb45b377799d89 to your computer and use it in GitHub Desktop.
Save Zadigo/0aa7fc579b4256b508eb45b377799d89 to your computer and use it in GitHub Desktop.
Assigning a macro to any given shape in Excel
Option Explicit
Sub assign_MacroToShape()
'
' This macro assigns a macro to a given shape
'
'Set variables
Dim active_Book As Workbook
Set active_Book = ActiveWorkbook
Dim active_Sheet As Worksheet
Set active_Sheet = Worksheets(ActiveSheet.Index)
Dim assignMacro as String
assignMacro = "'" & activeBook.Name & "'!macro_to_Assign"
'Assign macro
u.Shapes.Item(1).OnAction = assignMacro
End Sub
Sub macro_to_Assign()
'TO DO
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment