copy and paste vb

Posted on 2011-03-02
Last Modified: 2012-08-14
Can some please help with the below.

Excel VB crashes on the paste section. Not sure why.
For temp_indx = 1 To temp_num_sheets
    Sheets(Array("one", "Chart_2")).Select
    Sheets(Array("one", "Chart_2")).Copy
    Sheets(Array("one", "Chart_2")).Paste 
    Sheets(Array("one", "Chart_2")).Protect Password:="asdf", DrawingObjects:=True, Contents:=True, Scenarios:=True
    Sheets(Array("one", "Chart_2")).Select

Open in new window

Question by:jk_12
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 10

Expert Comment

ID: 35024112
Looks to me like you are copying two sheets and trying to paste them on top of themselves multiple times.

  What are you actually trying to acheive?

Author Comment

ID: 35024124
Thank you for the response.

I have an excel file which creates five unique reports. (Company 1, Company 2, etc).

Right now, it's 1 sheet report. I'm trying to add a second sheet into the automation process.
LVL 10

Accepted Solution

Makrini earned 250 total points
ID: 35024137

    Sheets(Array("one", "Chart_2")).Copy Before:=Sheets(1)

Open in new window


Author Closing Comment

ID: 35024189
Thanks very much.
LVL 10

Expert Comment

ID: 35024223
Glad to help

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question