I have the 4 macros below that I run on a worksheet. Everytime I hit one of the buttons first time, I get an error. I have to delete the popout and then it starts working fine. When I bring up that worksheet up again later, same thing happens.
Sub RunRisk()
'delete previous picture
DeletePicture
'create new picture centrally placed
Application.ScreenUpdating = False
Sheets("Charts").Range("B2:k13").Copy
With ActiveSheet
.Pictures.Paste
With .Shapes(.Shapes.Count)
.Name = "TablePicture"
.OnAction = "DeletePicture"
.Left = (ActiveWindow.VisibleRange.Width - .Width) / 3
.Top = (ActiveWindow.VisibleRange.Height - .Height) / 3
End With
End With
End Sub
Sub DeletePicture()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Name = "TablePicture" Then shp.Delete
Next shp
End Sub
Sub Assist()
'delete previous picture
DeletePicture2
'create new picture centrally placed
Application.ScreenUpdating = False
Sheets("Charts").Range("B15:f20").Copy
With ActiveSheet
.Pictures.Paste
With .Shapes(.Shapes.Count)
.Name = "TablePicture"
.OnAction = "DeletePicture2"
.Left = (ActiveWindow.VisibleRange.Width - .Width) / 3
.Top = (ActiveWindow.VisibleRange.Height - .Height) / 3
End With
End With
End Sub
Sub DeletePicture2()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Name = "TablePicture" Then shp.Delete
Next shp
End Sub
Sub InfieldIn()
'delete previous picture
DeletePicture3
'create new picture centrally placed
Application.ScreenUpdating = False
Sheets("Charts").Range("h15:j19").Copy
With ActiveSheet
.Pictures.Paste
With .Shapes(.Shapes.Count)
.Name = "TablePicture"
.OnAction = "DeletePicture3"
.Left = (ActiveWindow.VisibleRange.Width - .Width) / 2
.Top = (ActiveWindow.VisibleRange.Height - .Height) / 2
End With
End With
End Sub
Sub DeletePicture3()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Name = "TablePicture" Then shp.Delete
Next shp
End Sub
Sub OutfieldIn()
'delete previous picture
DeletePicture4
'create new picture centrally placed
Application.ScreenUpdating = False
Sheets("Charts").Range("h21:j25").Copy
With ActiveSheet
.Pictures.Paste
With .Shapes(.Shapes.Count)
.Name = "TablePicture"
.OnAction = "DeletePicture4"
.Left = (ActiveWindow.VisibleRange.Width - .Width) / 2
.Top = (ActiveWindow.VisibleRange.Height - .Height) / 2
End With
End With
End Sub
Sub DeletePicture4()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Name = "TablePicture" Then shp.Delete
Next shp
End Sub
Sub RunRisk()
'delete previous picture
DeletePicture
'create new picture centrally placed
Application.ScreenUpdating = False
Sheets("Charts").Range("B2:k13").Copy
With ActiveSheet
.Pictures.Paste
With .Shapes(.Shapes.Count)
.Name = "TablePicture"
.OnAction = "DeletePicture"
.Left = (ActiveWindow.VisibleRange.Width - .Width) / 3
.Top = (ActiveWindow.VisibleRange.Height - .Height) / 3
End With
End With
End Sub
Sub DeletePicture()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Name = "TablePicture" Then shp.Delete
Next shp
End Sub
Sub Assist()
'delete previous picture
DeletePicture2
'create new picture centrally placed
Application.ScreenUpdating = False
Sheets("Charts").Range("B15:f20").Copy
With ActiveSheet
.Pictures.Paste
With .Shapes(.Shapes.Count)
.Name = "TablePicture"
.OnAction = "DeletePicture2"
.Left = (ActiveWindow.VisibleRange.Width - .Width) / 3
.Top = (ActiveWindow.VisibleRange.Height - .Height) / 3
End With
End With
End Sub
Sub DeletePicture2()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Name = "TablePicture" Then shp.Delete
Next shp
End Sub
Sub InfieldIn()
'delete previous picture
DeletePicture3
'create new picture centrally placed
Application.ScreenUpdating = False
Sheets("Charts").Range("h15:j19").Copy
With ActiveSheet
.Pictures.Paste
With .Shapes(.Shapes.Count)
.Name = "TablePicture"
.OnAction = "DeletePicture3"
.Left = (ActiveWindow.VisibleRange.Width - .Width) / 2
.Top = (ActiveWindow.VisibleRange.Height - .Height) / 2
End With
End With
End Sub
Sub DeletePicture3()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Name = "TablePicture" Then shp.Delete
Next shp
End Sub
Sub OutfieldIn()
'delete previous picture
DeletePicture4
'create new picture centrally placed
Application.ScreenUpdating = False
Sheets("Charts").Range("h21:j25").Copy
With ActiveSheet
.Pictures.Paste
With .Shapes(.Shapes.Count)
.Name = "TablePicture"
.OnAction = "DeletePicture4"
.Left = (ActiveWindow.VisibleRange.Width - .Width) / 2
.Top = (ActiveWindow.VisibleRange.Height - .Height) / 2
End With
End With
End Sub
Sub DeletePicture4()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Name = "TablePicture" Then shp.Delete
Next shp
End Sub