0

I'm new with VBA, so I'm trying to create a macro button that can copy paste data from one worksheet to another but I think my code is flawed because the worksheet flickers whenever I run the code

tried a simple code since I'm new with VBA

Worksheets("Survey Form").Range("C9").Copy
Worksheets("Database").Activate
Cells(Rows.Count, 1).End(xlUp).Select
ActiveCell.Offset(1).Select
ActiveCell.PasteSpecial xlPasteValues
Worksheets("Survey Form").Activate
Application.CutCopyMode = False

I want the code to run smoothly without that flicker

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
  • 1
    Get rid of all the `.Select` and `.Activate` see here how to do that: https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba – Scott Craner Apr 24 '19 at 21:58
  • 3
    `Worksheets("Database").Cells(Rows.Count, 1).End(xlUp).Offset(1).Value = Worksheets("Survey Form").Range("C9").Value` Is all you need. and it will not flicker. – Scott Craner Apr 24 '19 at 21:59
  • @ScottCraner, Thank you so much for your help it solved my issue – Mark Stone Apr 24 '19 at 22:47

1 Answers1

0

In addition to what was suggested in the comments, you should also try this:

Sub something()

Application.ScreenUpdating = False
'
'
'the rest of your code here
'
'
Application.ScreenUpdating = True

End Sub

This should actually make your code run both smoother and faster.

Stavros Jon
  • 1,695
  • 2
  • 7
  • 17