Jamie McMillan
Board Regular
- Joined
- Nov 8, 2021
- Messages
- 169
- Office Version
- 2016
- Platform
- Windows
Hello,
I have Shapes named ,1, 2, 3, 4
The Macros assigned to each shape are called, 1, 2, 3, 4
Another shape called A, 'macro called A', selects one of these shapes, based on a cell value, Range("Q2").Value, of (1, 2, 3 or 4)
If the macro selects shape 1 I want it to then Call 1 (Call Macro 1), If the macro selects shape 3 I want it to then Call 3 (Call Macro 3)
Sub onetwo()
Dim Mac As Variant (I have tried using, long, string, ... etc)
Set Mac = ActiveSheet.Shapes(Application.Caller).Name (I have tried not using Set - just Mac = ActiveSheet.Shapes(Application.Caller).Name )
If Range("Q2").Value = 1 Then
ActiveSheet.Shapes.Range(Array("1")).Select
Selection.ShapeRange.ZOrder msoBringToFront
Else
If Range("Q2").Value = 2 Then
ActiveSheet.Shapes.Range(Array("2")).Select
Selection.ShapeRange.ZOrder msoBringToFront
Else
If Range("Q2").Value = 3 Then
ActiveSheet.Shapes.Range(Array("3")).Select
Selection.ShapeRange.ZOrder msoBringToFront
Else
If Range("Q2").Value = 4 Then
ActiveSheet.Shapes.Range(Array("4")).Select
Selection.ShapeRange.ZOrder msoBringToFront
End If
End If
End If
End If
Call Mac
End Sub
I have Shapes named ,1, 2, 3, 4
The Macros assigned to each shape are called, 1, 2, 3, 4
Another shape called A, 'macro called A', selects one of these shapes, based on a cell value, Range("Q2").Value, of (1, 2, 3 or 4)
If the macro selects shape 1 I want it to then Call 1 (Call Macro 1), If the macro selects shape 3 I want it to then Call 3 (Call Macro 3)
Sub onetwo()
Dim Mac As Variant (I have tried using, long, string, ... etc)
Set Mac = ActiveSheet.Shapes(Application.Caller).Name (I have tried not using Set - just Mac = ActiveSheet.Shapes(Application.Caller).Name )
If Range("Q2").Value = 1 Then
ActiveSheet.Shapes.Range(Array("1")).Select
Selection.ShapeRange.ZOrder msoBringToFront
Else
If Range("Q2").Value = 2 Then
ActiveSheet.Shapes.Range(Array("2")).Select
Selection.ShapeRange.ZOrder msoBringToFront
Else
If Range("Q2").Value = 3 Then
ActiveSheet.Shapes.Range(Array("3")).Select
Selection.ShapeRange.ZOrder msoBringToFront
Else
If Range("Q2").Value = 4 Then
ActiveSheet.Shapes.Range(Array("4")).Select
Selection.ShapeRange.ZOrder msoBringToFront
End If
End If
End If
End If
Call Mac
End Sub