+ Reply to Thread
Results 1 to 2 of 2

rotating shapes in Excel worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    02-05-2011
    Location
    Corunna, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    1

    rotating shapes in Excel worksheet

    I've created a macro which rotates a circle -15 degrees each time the macro is called. The code which does the rotation is...Selection.ShapeRange.IncrementRotation -15. I would like to be able to change the
    -15 value by using a "scroll" button on my worksheet, rather than having to go inside the macro and change the value. Is this possible?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: rotating shapes in Excel worksheet

    You can use a user defined function.

    Public Function udfROTATE_SHAPE(Value, Name)
        
        Dim shpTemp As Shape
        
        On Error GoTo Err
        Set shpTemp = ActiveSheet.Shapes(Name)
        shpTemp.Rotation = Value
        udfROTATE_SHAPE = True
        
        Exit Function
    Err:
        If shpTemp Is Nothing Then
            udfROTATE_SHAPE = CVErr(xlErrName)
        Else
            udfROTATE_SHAPE = CVErr(xlErrValue)
        End If
        Exit Function
        
    End Function
    called from cell using formula. This assumes scrollbar is linked to cell G1 and the shape is called 'Oval 1'

    =udfROTATE_SHAPE(G1,"Oval 1")
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1