Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 734
  • Last Modified:

copy and paste vb

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
jk_12
Asked:
jk_12
  • 3
  • 2
1 Solution
 
MakriniCommented:
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
 
jk_12Author Commented:
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
 
MakriniCommented:
try

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

Open in new window

0
 
jk_12Author Commented:
Thanks very much.
0
 
MakriniCommented:
Glad to help
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now