Results 1 to 6 of 6

VBA code to ungroup worksheets

Threaded View

  1. #1
    Registered User
    Join Date
    09-14-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    7

    VBA code to ungroup worksheets

    Hi All,

    Excuse my VBA, its a bit rusty. But i wrote a code, to copy worksheets from one workbook, to another workbook, that gets sent out to a mailing list. The issue is after doing so, the original workbook, groups all the tabs. I would like your help to amend the code to ungroup the tabs in the original workbook.

    I think the issue is in the initial sheets(array()) line which initially groups it

    Thanks


    Here is the code I have:

    Sub ExportNewFile()
    
    On Error GoTo errorHandler
    ' '*****Part 1: Define location to save the exported files***
    
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
        
    Dim NewName As String
    
        thisAppwin = Application.ActiveWorkbook.Name
        strpath = Application.ActiveWorkbook.Path & "\"
        cdir = Left(strpath & thisAppwin, Len(strpath) + Len(thisAppwin) - 5)
        NewName = cdir & "_EXPORT" ' & thisAppwin
        
        
        Sheets(Array("DATA", "UK", "EU7", "EU28", "GLOBAL" _
            , "PRINT")).Select
      
        Sheets(Array("DATA", "UK", "EU7", "EU28", "GLOBAL" _
            , "PRINT")).Copy
        
    
            ActiveWorkbook.SaveAs Filename:= _
            NewName & ".xlsx", _
            FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
           
    
        Sheets("PRINT").Activate
        ActiveSheet.Buttons.Delete
        Sheets("DATA").Activate
        ActiveSheet.Buttons.Delete
        
       Range("I1").Select
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
       Range("A1").Select
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
        ActiveWorkbook.Save
       MsgBox ("Your Excel file to send out is in the same folder; " & NewName), vbOKOnly
     Exit Sub
    
    errorHandler:
       MsgBox ("There has been an error. Please contact IT for support")
       
    End Sub
    Last edited by Oilking; 02-27-2014 at 07:27 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Ungroup selected worksheets after Before_Print event
    By clng in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-27-2010, 11:53 PM
  2. Group/Ungroup
    By rz6657 in forum Excel General
    Replies: 1
    Last Post: 03-26-2009, 02:55 AM
  3. Group and Ungroup Macro
    By caliskier in forum Excel General
    Replies: 2
    Last Post: 09-20-2007, 02:31 PM
  4. Help with Group/Ungroup
    By deacs in forum Excel General
    Replies: 3
    Last Post: 01-30-2006, 12:30 PM
  5. [SOLVED] how do you ungroup a spreadsheet
    By Sparkle in forum Excel General
    Replies: 1
    Last Post: 12-16-2005, 01:00 PM

Tags for this Thread

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