P
Paige
I have added an autoshape, then copied an Excel table over to it, and grouped
them together. In VB there is the following code, that brings up the
autoshape whenever someone clicks on a cell in the range of L2:L200, and
anchors the shape to that cell:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Box190 As Shape
Set Box190 = Me.Shapes("Group 190")
If Not (Intersect(Target, Range("L2:L200")) Is Nothing) Then
With Target
Shapes("Group 190").Visible = True
If Selection.Left + Selection.Width + Box190.Width > Rows(1).Width
Then
Box190.Left = Selection.Left - Box190.Width
Else: Box190.Left = Selection.Left + Selection.Width
End If
If Selection.Top + Selection.Height + Box190.Height >
Columns(1).Height Then
Box190.Top = Selection.Top - Box190.Height
Else: Box190.Top = Selection.Top + Selection.Height
End If
Box190.ZOrder msoBringToFront
End With
Else: Shapes("Group 190").Visible = False
End If
The problem is that the autoshape keeps changing sizes, I assume as a result
of other copy/paste/clear actions taken at different times. I have tried
setting the format of each autoshape (including the original shape, the
picture added, and the group) to all variations possible...don't move/size,
etc. When the other macros are run to copy/paste/clear, I set
application.enableevents to false. I can't figure out why the size of the
shapes keeps changing, and was wondering if it had something to do with the
above code .
Am really really frustrated with this and was hoping someone out there could
help me.....thanks so much.....
them together. In VB there is the following code, that brings up the
autoshape whenever someone clicks on a cell in the range of L2:L200, and
anchors the shape to that cell:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Box190 As Shape
Set Box190 = Me.Shapes("Group 190")
If Not (Intersect(Target, Range("L2:L200")) Is Nothing) Then
With Target
Shapes("Group 190").Visible = True
If Selection.Left + Selection.Width + Box190.Width > Rows(1).Width
Then
Box190.Left = Selection.Left - Box190.Width
Else: Box190.Left = Selection.Left + Selection.Width
End If
If Selection.Top + Selection.Height + Box190.Height >
Columns(1).Height Then
Box190.Top = Selection.Top - Box190.Height
Else: Box190.Top = Selection.Top + Selection.Height
End If
Box190.ZOrder msoBringToFront
End With
Else: Shapes("Group 190").Visible = False
End If
The problem is that the autoshape keeps changing sizes, I assume as a result
of other copy/paste/clear actions taken at different times. I have tried
setting the format of each autoshape (including the original shape, the
picture added, and the group) to all variations possible...don't move/size,
etc. When the other macros are run to copy/paste/clear, I set
application.enableevents to false. I can't figure out why the size of the
shapes keeps changing, and was wondering if it had something to do with the
above code .
Am really really frustrated with this and was hoping someone out there could
help me.....thanks so much.....