Copy without Select

Jaamie

Board Regular
Joined
Apr 16, 2003
Messages
224
Office Version
  1. 2016
Platform
  1. Windows
The following code works but formats change and that cause me problems
Rich (BB code):
Workbooks(MacroBook$).Worksheets("Control").Range("TranB4ChgA").Value = Workbooks(MacroBook$).Worksheets("Control").Range("TranNowA").Value

I'd like to copy Values and keep Number formats. I tried the following but I get Error 13 Type Mismatch. I tried Value instead of Value2 first but same result. How can I get the desired result?

VBA Code:
 Workbooks(MacroBook$).Worksheets("Control").Range("TranB4ChgA").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
          xlNone, SkipBlanks:=False, Transpose:=False = Workbooks(MacroBook$).Worksheets("Control").Range("TranNowA").Value2
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Maybe...
VBA Code:
Workbooks(MacroBook$).Worksheets("Control").Range("TranNowA").Copy
Workbooks(MacroBook$).Worksheets("Control").Range("TranB4ChgA").PasteSpecial xlPasteValuesAndNumberFormats
Application.CutCopyMode = False
 
Upvote 0
Thank you Mark858. I had already tried that and it does work, however the screen flicks over to the "Control" sheet and Back to the Activesheet even with Screenupdating - False. I was trying to avoid that if possible.
 
Upvote 0
It should not flick over to a different sheet at all unless you have added either Select or Activate to the code somewhere.
 
Upvote 0
For some reason it does. I put a stop on the next instruction Here is the code. 2 identical copies. The code in my first Post above doesn't flicker but results in format issues??

VBA Code:
      Workbooks(MacroBook$).Worksheets("Control").Range("TranNowA").Copy
      Workbooks(MacroBook$).Worksheets("Control").Range("TranB4ChgA").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
          xlNone, SkipBlanks:=False, Transpose:=False
      Workbooks(MacroBook$).Worksheets("Control").Range("TranNowB").Copy
      Workbooks(MacroBook$).Worksheets("Control").Range("TranB4ChgB").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
          xlNone, SkipBlanks:=False, Transpose:=False
      Application.CutCopyMode = False
 
Upvote 0
Are you sure that it is the Control sheet that appears in the flicker?
 
Upvote 0
Yes. The Control Sheet is Yellow and easy to spot. If I step thru, I don't see it. Also, it is not the CutCopyMode statement.

There are 2 copy statements. I tried them one at a time and still see the Flicker??

If I can't figure it out, I;ll have to live with the Flicker. The non-flicker alternative causes me more trouble.

Thank you for your help with this.
 
Upvote 0

Forum statistics

Threads
1,215,588
Messages
6,125,691
Members
449,250
Latest member
azur3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top