Consulting

Results 1 to 2 of 2

Thread: Copy specific multiple groups of sheets to new workbooks

  1. #1
    VBAX Newbie
    Joined
    Jul 2010
    Posts
    1
    Location

    Copy specific multiple groups of sheets to new workbooks

    Hi all,
    I need to develop a macro that copies (just the values not formulas)
    3 separate groups of specific sheets to 3 new workbooks.

    for example sheets X,Y,Z have to be copied to new workbook named
    Original's workbook name.X.xls and A,B,C, to Original's workbook name.A.xls , K,L,M to Original's workbook name.K.xls respectively

    I've found the following code in the knowledge base, which does exactly what I want but just for ne group (array )
    *t*p://**w.vbaexpress.com/kb/getarticle.php?kb_id=359

    apparently I cannot yet post links so just replace the *

    would please advice how to modify the code in order to operate with
    3 arrays?

    I'm new to VBA and don't clearly understand the following part
     For Each ws In ActiveWorkbook.Worksheets 
                ws.Cells.Copy 
                ws.[A1].PasteSpecial Paste:=xlValues 
                ws.Cells.Hyperlinks.Delete 
                Application.CutCopyMode = False 
                Cells(1, 1).Select 
                ws.Activate 
            Next ws 
            Cells(1, 1).Select
    or mmore precisely how this is related to the Sheets(array("X","Y","Z") ?
    I mean what cells it paste in the new workbook considering that it is not referring to the array, to my understanding!?
    Which of course is wrong as the code works - so if anyone would advice, explain it to me !!

    I have to learn the VBA, and this is the best way, I guess

    Thank you in advance!

    P.S. the renaming pattern I solved it that way
    [VBA]NewName = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) + ".XYZ"[/VBA]

    where .XYZ could be a variable or to call it as a string directly from the arrays once i understand how the above code works

  2. #2
    VBAX Regular
    Joined
    Jan 2007
    Location
    BrisVegas
    Posts
    25
    Location
     For Each ws In ActiveWorkbook.Worksheets 
                ws.Cells.Copy 
                ws.[A1].PasteSpecial Paste:=xlValues 
                ws.Cells.Hyperlinks.Delete 
                Application.CutCopyMode = False 
                Cells(1, 1).Select 
                ws.Activate 
            Next ws 
            Cells(1, 1).Select
    the above copies your worksheets and then pastes them as values, removing hyperlinks as well. it loops through each worksheet in the book and repeats the actions

Posting Permissions

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