Solved

copy and paste vb

Posted on 2011-03-02
5
722 Views
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
Next

Open in new window

0
Comment
Question by:jk_12
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:Makrini
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?
0
 

Author Comment

by:jk_12
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.
0
 
LVL 10

Accepted Solution

by:
Makrini earned 250 total points
ID: 35024137
try

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

Open in new window

0
 

Author Closing Comment

by:jk_12
ID: 35024189
Thanks very much.
0
 
LVL 10

Expert Comment

by:Makrini
ID: 35024223
Glad to help
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

813 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now