0

Does anyone know how to call a macro from the name contained in a cell?

I would like to resize a chart based on a combination of two cells values (M=Medium, C= Center) I then combine these together to get Size_Position=M_C. I created another macro named sub M_C() and used call Size_Position to try to call that specific macro. This did not work so I tried passing Size_Position to a cell and then calling that cell

Call Range("A6")

But this did not work either. Any ideas? Posted is the relevant code

Size_Position = Cells(i + 12, 4).Text & "_" & Cells(i + 12, 5).Text
Range("A6") = Size_Position

'Calls Sizing and Positioning macros
Call Size_Position
'Or Call range("A6")
Community
  • 1
  • 1
Jordan
  • 363
  • 4
  • 23
  • I don't understand your question at all. `Call Range("A6")` here `range` is not a macro, so how can you call it? What are you trying to achieve? – Raunak Thomas Apr 19 '18 at 17:46
  • 1
    Possible duplicate of [Call a macro which name is in the text of a cell](https://stackoverflow.com/questions/28037138/call-a-macro-which-name-is-in-the-text-of-a-cell) – omegastripes Apr 19 '18 at 17:48

1 Answers1

0

Use Application.Run

Sub MAIN()
    Application.Run Range("A6").Value
End Sub

Sub Macro1()
    MsgBox "Hello World"
End Sub

enter image description here

Gary's Student
  • 95,722
  • 10
  • 59
  • 99