Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 13th, 2008, 02:28 PM
Registered User
 
Join Date: Jun 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Open Workbook,Copy Sheet,Move Sheet, Close/Save

With the code I have, if I comment out the Open and the Close/Save code it will make a copy of the sheet and move it to the right workbook, but if I dont comment it out it wont. It will open,close, and save but without the sheet copied and moved.I need it to open a workbook, make a copy of a sheet from a different workbook, move the copied sheet to the NEW workbook, then save and close the new workbook. Any ideas? Also, how could I copy, move, save, and close specific columns (F,G,and H)?

Sub Copier1()
    'Opens workbook
   Workbooks.Open "C:\Documents and Settings\pruss\My Documents\NEW.xls" '
   'Makes a copy of "Sheet1"
    ActiveWorkbook.Sheets("Sheet1").Copy _
       after:=ActiveWorkbook.Sheets("Sheet1")
       'Moves that copy to "NEW.xls" workbook
        ActiveSheet.Move Before:=Workbooks("NEW.xls").Sheets(1)
        ActiveSheet.Next.Select
       'Closes "NEW.xls" workbook and saves the copied sheeet
       ActiveWorkbook.Close SaveChanges:=True

      End Sub


Thanks,








Similar Threads
Thread Thread Starter Forum Replies Last Post
how to save as an excel sheet azizsaad19 Beginning VB 6 2 May 25th, 2007 09:48 AM
Copy specific data from one sheet to another yogeshyl Excel VBA 2 May 11th, 2007 09:14 AM
OptionButtons as workbook sheet selector frankjuel Excel VBA 8 February 27th, 2007 05:32 PM
Copy one sheet to another file shamigc Excel VBA 2 April 13th, 2005 06:45 AM
Code to populate multiple sheet into workbook kud Excel VBA 0 June 9th, 2004 11:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.