Share via

Command Button Icon Gets Duplicated After Click Event is Performed

Anonymous
2010-09-04T18:59:08+00:00

I have an Active X Command button that copies a range and pastes it into another location. The changed cells move on the screen vertically a bit leaving two pictures of the Command button – one apparently real and one where the Command button used to be before the click event.. I can get rid of the duplicate by scrolling or clicking the ‘real’ Command button again. The screen window has a horizontal partition – the top 3 rows are always viewable.

Here is the code I used.

Private Sub CommandButton1_Click()

  Range("H103:T115").Select

    Selection.Copy

    Range("H25").Select

    ActiveSheet.Paste

End Sub

How do I automatically prevent the second command button picture?

EDIT: I added

Appication ScreenUpdating = False at the beginning of the code

and

Application ScreenUpdating =True at the end.

That seems to do the trick. Is this the way or am I just temporarily lucky?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. OssieMac 48,001 Reputation points Volunteer Moderator
    2010-09-04T21:38:59+00:00

    I have had this "ghosting" before but under different conditions. One suggestion was to uninstall the video driver and reinstall it. However, that did not fix it and I just put up with it until it came time to do a total re-installation of windows and software due to other problems and the ghosting problem has not been there since so I am suggesting it is a glitch in the software somewhere.

    However, there is no need to select ranges for copy and paste. The following copies and pastes in one line. Note it is one line with just a space between Copy and Destination. It might alleviate your problem.

    Private Sub CommandButton1_Click()

      Range("H103:T115").Copy Destination:=Range("H25")

    End Sub


    Regards, OssieMac

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments