+ Reply to Thread
Results 1 to 2 of 2

Moving Buttons on a Worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    02-14-2013
    Location
    London
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    15

    Moving Buttons on a Worksheet

    Hi,

    I'm stuck how to adapt the following code to what I need.


    Sub ButtonsRenamed2()
    
    r = 0
    For Each myButton In ActiveSheet.Shapes
    If Left(myButton.Name, 6) = "Button" Then
    
    myButton.Select
    With Selection
        .Top = 10
        .Left = 15 + r
    End With
    
    End If
    r = r + 85
    
    Next myButton
    End Sub
    While this works, its not putting the buttons in the order i want, which is Button 2 to Button 43 in order. (will need as the next stage to sort into 3 rows!)

    So rather than a for each, i need to step through 2 to 43

    Can't get the syntax right on myButton = ........

    Sub ButtonsRenamed2()
    Dim myButton As Shape
    r = 0
    For i = 2 To 44 Step 1
    
    myButton = ActiveSheet.Shapes.Button(i)
    
    myButton.Select
    With Selection
        .Top = 10
        .Left = 15 + r
    End With
    
    r = r + 85
    
    Next i
    
    End Sub

  2. #2
    Registered User
    Join Date
    02-14-2013
    Location
    London
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    15

    Re: Moving Buttons on a Worksheet

    My current solution to the above is....

    Sub ButtonsRenamed2()
    Dim myButton As Shape
    Dim Button As Shape
    r = 0
    s = 0
    For i = 2 To 44 Step 1
    
    On Error Resume Next
    ButtonNumb = "Button " & (i)
    Set myButton = ActiveSheet.Shapes(ButtonNumb)
    myButton.Select
    
    With Selection
        .Top = 10
        .Left = 15 + r
    End With
    
    r = r + 85
    
    Next i
    
    
    End Sub

+ 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