• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macros

Sreeraj

New Member
i wrote some macros to display graphs based on some buttons. But when I click on the second button, a piece of the previous graph appears behind the new graph. How can i avoid this?
 
Welcome to the forum.

This sounds like it's entirely dependent on how the macro is written and what it is doing. Are all the charts built, and macro toggles then on off? Is your macro properly changing the Visible setting on the charts? Is ScreenUpdating being turned on/off properly?
 
This is the macro:
Code:
Sub EntityUniWCR()
'
' EntityUniWCR Macro
'

'
    Application.ScreenUpdating = False
    Rows("12:153").Select
    Selection.Delete Shift:=xlUp
    Sheets("Data WCR").Select
    ActiveSheet.ChartObjects("Chart 4").Activate
    ActiveChart.ChartArea.Copy
    Sheets("WCR4000").Select
    Range("B11").Select
    ActiveSheet.Paste
    Range("L114").Select
    Application.ScreenUpdating = True
End Sub
Sub EntityRevWCR()
'
' EntityRevWCR Macro
'

'
    Application.ScreenUpdating = False
    Rows("12:160").Select
    Selection.Delete Shift:=xlUp
    Sheets("Data WCR").Select
    ActiveSheet.ChartObjects("Chart 3").Activate
    ActiveChart.ChartArea.Copy
    Sheets("WCR4000").Select
    Range("B11").Select
    ActiveSheet.Paste
    Range("L114").Select
    Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:
When you delete the rows, it doesn't necessarily delete the shapes/charts that are floating on top of them. It might just shrink the size down to 0, trying to size the chart with the rows. Can you perhaps instead select the chart directly and delete it?
Code:
ActiveSheet.ChartObjects(1).Delete
 
Back
Top