Solved

Prevent Group display

Posted on 2012-03-13
6
176 Views
Last Modified: 2012-03-14
I need Experts advice. Is a way for us not to display the vertical group (+) option when I export the attached workbook by using the "Sub moveDifFolder" module?
RemoveGroup.xls
0
Comment
Question by:Billa7
  • 3
  • 3
6 Comments
 
LVL 41

Expert Comment

by:dlmille
ID: 37718298
Just add the .Rows.Ungroup method to your worksheet.

Option Explicit

Sub moveDifFolder()
Dim wkb As Workbook
Dim newWkb As Workbook
Dim wks As Worksheet
Dim oPic As Object
Dim sPath As String
Dim fName As String
Dim fPathName As String

    Set wkb = ThisWorkbook
    sPath = "C:\temp"
    With wkb.Worksheets("Data")
    Range("AT2") = "_Issued on " & Format(Now, "mm.dd.yyyy"" @ ""hhmm")
        fName = .Range("AW1") & .Range("AV1")
        .Rows.Ungroup
    End With
    
    fPathName = sPath & "\" & fName
    
    Application.DisplayAlerts = False
    
    wkb.Sheets.Copy
    
    Set newWkb = ActiveWorkbook
    
    'delete pictures
    For Each wks In newWkb.Worksheets
        For Each oPic In wks.Pictures
            oPic.Delete
        Next oPic
    Next wks
            
    'clear K:Q in Data sheet
    Set wks = newWkb.Worksheets("Data")
    'wks.Range("K:Q").Clear
    
    'Call RemoveAllMacros(newWkb)
    'Save the workbook
    
    newWkb.SaveAs Filename:=fPathName & ".xls", FileFormat:=xlExcel8
    newWkb.Close
    
    
    MsgBox "Process Complete!"
End Sub

Open in new window

0
 
LVL 41

Expert Comment

by:dlmille
ID: 37718301
So, for row group removal:

Wks.Rows.Ungroup

and for column group removal:

Wks.Columns.Ungroup

Cheers,

Dave
0
 

Author Comment

by:Billa7
ID: 37718602
Hi Dave,

The group removal need to be done at export file, not the source. Please assist.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Billa7
ID: 37719290
Hi Dave,

I have tried to copy "Wks.Rows.Ungroup" at exported wb but it shows as:

Invalid or unqualified reference.


Here's the line that I've tested:

Next wks
           
    'clear K:Q in Data sheet
    Set wks = newWkb.Worksheets("Data")
    .Rows.Ungroup
    'wks.Range("K:Q").Clear
0
 
LVL 41

Accepted Solution

by:
dlmille earned 500 total points
ID: 37720905
The wks.  in my example is just the variable that holds the worksheet object where you want to make the change.

You were close, but need to reference the wks object in your statement (in the previous post, you were doing a With, so I used .Rows.Ungroup.  In this instance, we can just reference the worksheet object directly (and we could have, in the prior post, as well).

Here's your modified code (See added line 36):
Option Explicit

Sub moveDifFolder()
Dim wkb As Workbook
Dim newWkb As Workbook
Dim wks As Worksheet
Dim oPic As Object
Dim sPath As String
Dim fName As String
Dim fPathName As String

    Set wkb = ThisWorkbook
    sPath = "C:\temp"
    With wkb.Worksheets("Data")
    Range("AT2") = "_Issued on " & Format(Now, "mm.dd.yyyy"" @ ""hhmm")
        fName = .Range("AW1") & .Range("AV1")
    End With
    
    fPathName = sPath & "\" & fName
    
    Application.DisplayAlerts = False
    
    wkb.Sheets.Copy
    
    Set newWkb = ActiveWorkbook
    
    'delete pictures
    For Each wks In newWkb.Worksheets
        For Each oPic In wks.Pictures
            oPic.Delete
        Next oPic
    Next wks
            
    'clear K:Q in Data sheet
    Set wks = newWkb.Worksheets("Data")
    wks.Rows.Ungroup
    'wks.Range("K:Q").Clear
    
    'Call RemoveAllMacros(newWkb)
    'Save the workbook
    
    newWkb.SaveAs Filename:=fPathName & ".xls", FileFormat:=xlExcel8
    newWkb.Close
    
    
    MsgBox "Process Complete!"
End Sub

Open in new window


Dave
0
 

Author Closing Comment

by:Billa7
ID: 37723145
Thanks a lot Dave
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now