You may be having trouble keeping track of which sheet is actually active. If you are activating various sheets, then the active sheet changes. I suggest that you set a worksheet variable to the activesheet early in the procedure and use that variable to provide the name.
For example, the code below will move the chart to Sheet1 if it is active when the procedure is run and will move it to Sheet2 is it is active when the procedure is run.
![]()
Sub doit() Dim a As Chart Dim b As Worksheet Set b = ActiveSheet Set a = Charts.Add Set a = a.Location(xlLocationAsObject, b.Name) End Sub
Bookmarks