PDA

View Full Version : Solved: Copy/Paste All Cells on a Non-active worksheet



JimS
01-26-2011, 01:36 PM
How can the following few lines of code be converted so that the worksheet does not have to be Activated?

JimS



Worksheets("Data1").Select

Cells.Select
Selection.Copy

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Cells.Select
Selection.Columns.AutoFit

ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowFormattingColumns:=True, Password:=""

mbarron
01-26-2011, 02:33 PM
Change Sheet2 to the correct destination sheet name.

Worksheets("Data1").Cells.Copy
Worksheets("sheet2").Range("a1").PasteSpecial Paste:=xlPasteValues
Worksheets("sheet2").Cells.Columns.AutoFit
Application.CutCopyMode = False
Worksheets("sheet2").Protect DrawingObjects:=False, Contents:=True, Scenarios:=True, _
AllowFormattingColumns:=True, Password:=""

JimS
01-26-2011, 03:14 PM
Thanks...