Help with vba to scroll group of shapes

Gregm66

Board Regular
Joined
Jan 23, 2016
Messages
170
Hi everyone,

I have shapes in my worksheets, these shapes have been grouped, i am trying to get these groups to scroll down as the user scrolls down the worksheet.
Below is the code i am using, my problem is that it keeps bugging at line Set myGroup.
is there something wrong here that i can not see...

Thanks in advance for any help.

Code:
'Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    'Dim effectiveBottomRow As Long
    'Dim myGroup As Object
    'Set myGroup = ActiveSheet.Group (11): Rem adjust
    
    'With ActiveWindow.VisibleRange
        'effectiveBottomRow = .Row + .Rows.count - 2
    'End With
    
    'With myGroup
        'myGroup.Top = myGroup.Top + (effectiveBottomRow - .BottomRightCell.Row) * .BottomRightCell.RowHeight
    'End With
'End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Ok i have sorted this one out myself.

Firstly i created a Macro, then created the sheet code, now my group of shapes follows as i select a cell, although i would like it to be auto as i scroll down.
see codes below.

Macro

Code:
Sub Creator()
    Dim shp As Shape


    Set shp = ActiveSheet.Shapes.AddShape(1, 100, 10, 60, 60)
    shp.Name = "MyButton"
End Sub

Sheet Code

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim sh As Shape, r As Range
    Set sh = ActiveSheet.Shapes("MyButton")
    Set r = ActiveCell
    sh.Top = r.Offset(-1, -2).Top
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top