PDA

View Full Version : Screen Refresh



chem101
10-25-2010, 07:14 AM
Hello Everyone,

I need your help. I'm using code to copy a small .jpeg from one worsheet to another within the same workbook. There are about 30 If then conditions used to determine where the pic will be pasted. As copying is done the screen flickers. Below is the first part of the code I'm using. Can you help me modify it so the screen doesn't flicker when the pic is being copied.

Thank you in advance for any help you can provide!!


Sub CopyWHMSTRPic()
Dim ws As Worksheet
Set ws = ActiveSheet


Application.ScreenUpdating = False

If Range("InputbxS").Value = "RS" And Range("InputJ").Value = "Tp3" Then

ws.Range("i33:ab45").CopyPicture
Worksheets("WH Master").Activate
Worksheets("WH Master").Range("c22").Activate
Worksheets("WH Master").Paste
End If
Application.ScreenUpdating = True
wksNewOrder.Activate
Range("A1").Select
Range("OrderNumber").Select

mbarron
10-25-2010, 09:02 AM
I'm seeing no flicker with the bit of code you've posted. Is this the complete code?

You an avoid the Activating of the sheet and range in this section:
Worksheets("WH Master").Activate
Worksheets("WH Master").Range("c22").Activate
Worksheets("WH Master").Paste

by using

Worksheets("WH Master").Range("c22").PasteSpecial


For readability of your posted code, please remember to use the VBA tags.

chem101
10-25-2010, 09:45 AM
There are about 30 If Then statements below the code that I posted. There all basically the same If Then statements just with different values and destinations for the pic. Pls advise

Thank you.

mbarron
10-25-2010, 09:59 AM
I'd advise to post the entire code. Without seeing it there is no way to know what it is doing.


One possiblity:
Is your entire module surrounded by the
Application.ScreenUpdating = False
...... your code ......
Application.ScreenUpdating = True

Your snippet shows that you turn the ScreenUpdating back on after the If statement. You should only turn it back on after the entire code has run.