Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excell - VBA copying from one worksheet to other 1

Status
Not open for further replies.

Evening

Technical User
Jan 19, 2005
45
CA
I have 2 worksheets in the workbook:
1) sheet-1
2) sheet-2

I am using VBA to do some processes in workbook.
I am in sheet-2, want to copy data to sheet-1.

Sheets("sheet-2").Range("A12:M1000").Copy
Sheets("sheet-1").Range("A10").Select ----> Run time error
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False'

Sheets("sheet-2").Range("A1").Select

I am getting runtime error 9.
 
Hi,

You don't need to select. in fact it slows down your program.
Code:
Sheets("sheet-2").Range("A12:M1000").Copy
Sheets("sheet-1").Range("A10").PasteSpecial _
  Paste:=xlPasteValues, Operation:=xlNone, _
  SkipBlanks:=False, Transpose:=False

with Sheets("sheet-2")
   .Activate
   .Range("A1").Select
End with


Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Thanks Skip, your help fixed my trouble, it works...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top