View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
michael.beckinsale michael.beckinsale is offline
external usenet poster
 
Posts: 274
Default Run another macro from within this macro

Hi Cathy,

Slight amendment to the code. It does work & therefore if l have
interpreted you requirements correctly avoids the need for 100
macro's.

Sub TiltShape()
' SetTruPointer Macro
Dim TiltValue As Integer
TiltValue = ActiveSheet.Range("A1").Value
ActiveSheet.Shapes("Line 41").Select
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Rotation = TiltValue
End Sub

The line will tilt to whatever value is entered into cell A1

If you want this to happen automatically whenever the value in A1 is
changed paste this code into the Sheet1 code module: (copy code, right
click Sheet1 tab, view code, paste)

Private Sub Worksheet_Change(ByVal Target As Range)

Dim TiltValue As Integer
If Target = Range("$A$1") Then
TiltValue = Worksheets("sheet1").Range("A1").Value
ActiveSheet.Shapes("Line 2").Select
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Rotation = TiltValue
End If

End Sub

Regards

Michael