Working with Python 2.7 and I'd like to add new sheets to a current Excel workbook indexed to a specific position. I know Openpyxl's create_sheet command will allow me to specify an index for a new sheet within an existing workbook, but there's a catch: Openpyxl will delete charts from an existing Excel workbook if opened & saved. And my workbook has charts that I don't wish to be deleted.
Is there another way I can open this workbook, create a a few blank sheets that are located precisely after the existing first sheet, all without deleting any of the workbook's charts?
openpyxl 2.5 includes read support for charts
Related
This my first post in this forum, and I am newbie to VBA. I thought to ask you whether you might have some ideas how to do the following task I am trying to accomplish in VBA:
I have more than 600 workbooks in a folder containing multiple spreadsheets. Each of spreadsheets contains some sort of data which I need to access their range and copy to new workbooks.
From sheets stored in one workbook for example I only need one, which is predominantly stored at Sheets index position 1, although in more than 100 workbook that is not the case. I already looped through all files in folder with Dir() function and know which workbooks do have sheets that I need on wrong index position. I need also to copy a range of that specific sheet to another workbook, which I am able to do but how to use VBA to find dynamically workbook I need and sheet by its index position. I really want to avoid opening workbooks via Dir function in a loop and do work manually.
How can I dynamically use an array or any other method and find those workbooks and sheets within workbooks that I am interested and either flag them through Boolean If statement and either have msg box pop out saying: “This sheet needs work”, or just copy the range to new workbook and save it along with the remainder of workbooks in a folder.
Any ideas or help would be much appreciated.
Many thanks
I am working with 40+ workbooks and need a list of every named tab in each one, for a cataloguing project. The only macros and instructions I found require creating a formula or macro for each workbook.
I have one file designated as the macro file. In it are two functions, one to sort tabs by color and one to sort them alphabetically. Both work on whatever workbook I have active, as long as the macro workbook is open in the background.
How can I list all the sheet names in the active workbook, using code from the macro workbook?
I don't mind running the command once for each workbook, but I don't want to create a macro in every file.
You can use Workbook.Sheets to access the sheets of a workbook.
Likewise, you can use Workbooks to access the open workbooks.
You can create a nested pair of For loops to iterate through all workbooks, and then all worksheets.
I have an Excel workbook with some VBA code in modules and in the worksheets. As I use the workbook, Excel will suddenly create ghost/phantom worksheets that can't be deleted. IN the screen shot below the original works sheets, Sheet17 (Main Menu ) and Sheet 25 (Results) ended up getting duplicated (Sheet17, Sheet171, Sheet1711, Sheet 17111; Sheet25, Sheet251, Sheet2511, Sheet25111, etc). The version less than Sheet17111 are ghost worksheets (notice the different icon) that can not be deleted. The VBA code for those worksheets stayed with the latest version of the worksheet (ie. Sheet17111).
The only way to get rid of the ghost worksheets is to save the workbook as an xlsx, close the workbook open up the xlsx, copy over the worksheet code and modules and save out the xlsm. Of course this only corrects the problem until the next occurrence
I am not calling any special addins.
Any tips on what I can try to correct this problem.
Ian
So i was writing a program that reads excel files using a .net library and i got confussed when i saw that some excel file has 2 worksheets. I opened it up in excel and tried to use unhide option, but it was grayed out as if there was no hidden sheets but when i unziped the excel file, then there where indeed 2 files in xl > worksheets folder.
Why it cannot be unhiden? Is there other option that could make worksheet invisible? Or did excel create this worksheet for something and it cannot be unhidden?
Ok, i found out that apparently excel worksheet can have state of "Visible", "Hidden" or "VeryHidden". Excel options hide and unhide toggle between states of Visible and Hidden.
The question is, how and when excel changes worksheet state to VeryHidden?
It seems that it can only be changed to VeryHidden using Visual Basic Editor.
You can also unzip excel file and manually change it inside workbook.xml located in xl folder.
I have been unable to find a solution for this problem: When adding a new worksheet in an Excel workbook, the active cell moves to D20. This behavior is consistent across ALL workbooks that I open or use (new or opening existing workbooks). There are no macros on "ThisWorkbook" or any of the sheets. Has anyone seen this before?
Did you (or someone else) maybe create a custom sheet template?
https://www.rondebruin.nl/win/s9/win016.htm
I saved a single-sheet workbook (with D20 selected) as "sheet.xlt" in my XLSTART folder, and each time I add a new sheet in a workbook I get that same selection in the new sheet.