Jump to content

separate single worksheet from group worksheet


 Share

Recommended Posts

Hi,

I have a workbook with group worksheet, I want to separate a single worksheet from group and delete all group worksheet.

is there any way to ungroup a single worksheet from group worksheet???

Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "Error!!!", "Unable to open excel")

Local $sWorkbook = $_sPath & "\" & ByYear.xlsx
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)
Local $_vUngroupSheet = $oWorkbook.Sheets("Jan2018").Activate

 

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

How to group worksheets is described here: https://bettersolutions.com/excel/worksheets/vba-grouping.htm

Ungrouping should work by only selecting a single worksheet.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

hi water,

I want to separate or deselect a single worksheet from a group worksheet without breaking the group worksheet then i will delete all the group worksheet.

I tried this line it is selecting the worksheet I want but it is ungrouping the other worksheet.

Local $_vUngroupSheet = $oWorkbook.Sheets("Jan2018").select

 

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

; Create an array containing the index of the selected sheets
Global $iSelectedSheets = $oWorkBook.ActiveWindow.SelectedSheets.Count ; How many sheets have been selected
Global $iUnselect = 1 ; Sheet to unselect
If $iSelectedSheets > 1 Then ; when there is a group of selected sheets
    Global $aSelectedSheets[$iSelectedSheets], $i = 0
    For $oSelectedSheet in $oWorkBook.ActiveWindow.SelectedSheets
        If $oSelectedSheet.Index <> $iUnselect Then 
            $aSelectedSheets[$i] = $oSelectedSheet.Index
            $i = $i + 1
        EndIf
    Next
    ; Unselect all selected sheets by only selecting the first sheet of the group
    $oWorkBook.Sheets($aSelectedSheets[0]).Select
    ; Select all other sheets
    $oExcel.Worksheets($aSelectedSheets).Select
EndIf

Set variable $iUnselect to the index of the sheet you want to remove from the group.
This code is totally untested (not even syntax checked) as I do not have AutoIt available at the moment.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...