+ Reply to Thread
Results 1 to 10 of 10

VBA - Open new sheet, Paste special values, save as

  1. #1
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    VBA - Open new sheet, Paste special values, save as

    Is anyone able to sort me out some VBA that I can attach to a button on each of the attached sheets.

    VBA - New sheet, Copy paste values, Saves as.xlsx

    Macro needs to,
    1. Copy the entire sheet which is open
    2. Open a new workbook
    3. Paste the values & formats
    4. Save the sheet as file name "mm yyyy & the sheet name from where it was copied" - Month and year will need to be taken from the sheet titled "save info".

    So basically, if the macro was run in sheet A. Then it would copy the sheet, open a new blank workbook, paste the values and formats, then save the new workbook as "04 2014 A"

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: VBA - Open new sheet, Paste special values, save as

    1 Range.Copy method
    2 Workbooks.Add method
    3 PasteSpecial method
    4 Activeworkbook.SaveAs method

    google these or type them in VBA and press F1, should get you started.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    Re: VBA - Open new sheet, Paste special values, save as

    Quote Originally Posted by nathansav View Post
    1 Range.Copy method
    2 Workbooks.Add method
    3 PasteSpecial method
    4 Activeworkbook.SaveAs method

    google these or type them in VBA and press F1, should get you started.
    Thanks, found some code, I've modified it to what I want, but I'm struggling with the last piece of the puzzle.

    VBA - New sheet, Copy paste values, Saves as.xlsm

    Atm, the worksheet called "Save info" is copied and saved, I don't want this sheet to be included.

    Also the parts of code where 04 2014 is, needs to be linked to cell B1 & B2 in the Save info worksheet
    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    Last edited by benoj2005; 05-28-2014 at 07:13 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: VBA - Open new sheet, Paste special values, save as

    Sourcewb.Path & "\" & range("b1").value & " " & range("b2").value

    you'll need to get all the worksheets into an array missing the save info one

    dim w as worksheet

    for each w in thisworkbook.worksheets

    if w.name<>"save info" then
    ADD TO ARRAY OF WORKSHEETS
    end if

    next w

    Copy this array to a new workboook.

  5. #5
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    Re: VBA - Open new sheet, Paste special values, save as

    VBA - New sheet, Copy paste values, Saves as.xlsm

    Changed the file names to include
    Please Login or Register  to view this content.
    Works fine for the folder, if I run the macro when on the worksheet called Save info, can live with that. However the only sheet that saves with the 04 2014 infornt of the file name is the Save info one.

    I need to reference the sheet Save info & cell b1, not just b1 in whatever the active sheet is.

    Not tried the array method, is there a recommended source for this code? Or even better if you could add it in, I'm new to this VBA lark!

  6. #6
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: VBA - Open new sheet, Paste special values, save as

    Worksheets(sheetname).range(address)

    this is all available on google, i'd start looking there at the Excel application model, how its put together, e.g. Application --> Workbook --> worksheets --> cells etc rather than pieceing together line by line.

  7. #7
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    Re: VBA - Open new sheet, Paste special values, save as

    Thanks, got it all working except not copying and saving the one particular sheet.

    I find using google for what I'm looking for difficult when I don't know the lingo. It's easy when you know the code you're looking for.

  8. #8
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: VBA - Open new sheet, Paste special values, save as


  9. #9
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    Re: VBA - Open new sheet, Paste special values, save as

    Yea I'd been on that, but it seemed I'd have to name all the sheets in the array, realised there's a much simpler way

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: VBA - Open new sheet, Paste special values, save as

    Sure, pop Option Compare Text at the top of your code, the very top. This will negate the case sensitibity of strings.

+ 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. Replies: 0
    Last Post: 01-29-2014, 07:38 AM
  2. 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
  3. Copy/Paste special form one sheet to another into first open colum
    By GeorgeD in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-28-2010, 05:50 PM
  4. Replies: 0
    Last Post: 05-24-2010, 05:17 PM
  5. Macro to Paste Special Values, Remove Sheets and Save
    By Dexta_Dark in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2008, 11:58 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