Solved

Prevent Group display

Posted on 2012-03-13
6
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 42

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 42

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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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 42

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 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