+ Reply to Thread
Results 1 to 6 of 6

VB Code to perform copy and paste values n closed workbook

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to perform copy and paste values n closed workbook

    Hello:

    Please refer to attached files.
    I have lots of files in a folder C:\Temp\.
    I need a vB Code to perform following task.
    In each file in a folder, i need the code to copy and paste Values in sheet1 Range H10:Q40 (Currently this range has formulas).
    Basically Copy Range (H10:Q40) and paste at cell H10 values only.

    Then delete Sheet2, Sheet3 of the file.
    Save the file by adding FINAL at the end of the file name.
    So if the file name is 05_2015_Store1.xls then save it as 05_2015_Store1_FINAL.xls

    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: VB Code to perform copy and paste values n closed workbook

    Hi, Riz,

    what about the original files, shall they stay in the same directory? Where to save the new file? A new directory or the same? Are there any files holding the addition in the directory?

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to perform copy and paste values n closed workbook

    Hi HahoBe:

    Seems to work.
    In the example i have uploaded has sheets 1,2 and 3.
    However in my actual work sheet names for all files will be the same as DailyMain, DailySales, DailySummary.
    Here need to delete DailySales and DailySummary and DailyMain will be the same as Sheet1 in teh above code.
    Please help correct code above and let me know if any questions.
    Also it would be nice to seperate out the _FINAL files in directory C:\Temp\Final\

    Please let me know if you have any questions.
    Thanks.

    Riz

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: VB Code to perform copy and paste values n closed workbook

    Hi, Riz,

    we have got to make sure that there will always remain at least one sheet in the workbook (in case of a misspelled sheet) when deleting sheets.

    Please try and see how the code is doing:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to perform copy and paste values n closed workbook

    Hi HaHoBe:

    Works except few exception, please see below.
    There are lots of other sheets which I do not need to delete.
    The names of the sheets i need to delete are : "Data1", "Data2","Data3".
    Please add the code to do this.
    Please let me know if you have any questions.
    Thanks a lot for great help.

    Riz
    Last edited by rizmomin; 06-08-2015 at 07:44 PM.

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to perform copy and paste values n closed workbook

    Hello HahoBe:

    I got this part working.
    I am working further and will contact you further for further help.
    Once again thanks a lot.
    Riz

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy and Paste in closed workbook
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2014, 08:31 AM
  2. [SOLVED] Code to copy data from a closed workbook and paste in active workbook using named range.
    By paullie1912 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-28-2014, 02:38 AM
  3. VBA code to open new workbook and copy and paste special values
    By oddinho2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 11:24 PM
  4. Copy and Paste from a Closed Workbook
    By Sean Ross in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2013, 10:26 AM
  5. Copy 2 sheets from a open workbook and paste to a closed workbook
    By grimston in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2012, 03:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1