fredrerik84
Active Member
- Joined
- Feb 26, 2017
- Messages
- 383
So I have this code that first deletes any old shapes (if any) then inserts new shape after. this code was not made by me and i'm having some troubles improving it..
originally it work like this:
cell G27 has a dropdown list and shape gets inserted into cell f27 , Im trying to get remake the code to put the shape straight into g27 removing the need for helper cell f27. I've been somewhat successful. here is my somewhat working code:
Ive highlighted problem area in red. This is the part that remove the old shape but after changing the shape location placement that line does not work as intended.
Does anyone see what missing for this code to work ?
the only change I have done to this code is here:
.Left = Target.Offset(0, -1).Left
to
.Left = Target.Offset(0, 0).Left
any help making me fix this would be much appreciated
originally it work like this:
cell G27 has a dropdown list and shape gets inserted into cell f27 , Im trying to get remake the code to put the shape straight into g27 removing the need for helper cell f27. I've been somewhat successful. here is my somewhat working code:
Rich (BB code):
If Not Cell Is Nothing Then
For Each shp In Shapes
If Round(shp.Left, 0) = Round(Target.Offset(0, 0).Left, 0) And Round(shp.Top, 0) = Round(Target.Offset(0, -1).Top, 0) Then
shp.Delete
Exit For
End If
Next shp
For Each shp In dws.Shapes
If shp.Left = Cell.Offset(0, 1).Left And shp.Top = Cell.Offset(0, 1).Top Then
Set nShp = shp.Duplicate
nShp.Cut
ActiveSheet.Paste
Application.CutCopyMode = 0
flag = True
Exit For
End If
Next shp
If flag Then
With Selection
.Left = Target.Offset(0, 0).Left
.Top = Target.Offset(0, -1).Top
.Width = Target.Offset(0, -1).Width
.Height = Target.Offset(0, -1).Height
Target.Select
End With
End If
End If
Ive highlighted problem area in red. This is the part that remove the old shape but after changing the shape location placement that line does not work as intended.
Does anyone see what missing for this code to work ?
the only change I have done to this code is here:
.Left = Target.Offset(0, -1).Left
to
.Left = Target.Offset(0, 0).Left
any help making me fix this would be much appreciated