I've tried doing multiple searches, but may be wording incorrectly giving me info that doesn't apply.
I have a macro that parses through data, creates a new workbook and within that, a new worksheet. I want to be able to throw a form control or some sort of option for the user to add more data after the fact. Follow a similar example below to get a better understanding.
Say I have a workbook that I call "analyzer" and takes some input, formats it and also adds a summary tab. For instance, I'm a business and have all transactions made in my small store for a given month in a spreadsheet, .txt file etc. This is the input that "analyzer" takes in and formats.
"Analyzer" has a form control button on it and when you click it, it pops open a dialog box for you to select whatever months you want to analyze. Let's say its March. When I click on that button, I select January and February, it creates a new workbook, we'll call "Month_eval", formats each month in it's own worksheet and then adds a summary worksheet at the end for a "quick glance" view. Now I have this workbook, "Monthly_eval" that has three worksheets, Jan, Feb and Summary, but no real easy way to add say March or any additional months and append them to it or the summary worksheet.
What I would like to is add a form control button to the "summary" tab/worksheet to basically analyze more months of data and append to "Month_eval". The problem is this doesn't exist until I run the "Analyzer" workbook. I can't figure out how to phrase/search this to get relevant results.
I think I should be able to get it from there by assigning a procedure to the button click.
I apologize if this is asked multiple times. If there is something relevant or almost identical, please post and I'll close the thread.
So from data in WBX you want to create a new workbook WBY with N worksheets containing monthly analysis, and this WBY will have the functionality to append additional data from WBX?
I think maybe you will need to create a class for this WBY.
Why not have a Summary workbook (SWB) and an analysis workbook (AWB). When you want to analyse the data you just export it from SWB to AWB and do your formulas and view it, instead of generating a new workbook everytime?
Related
Complete beginner with VBA and I think I'm doing something majorly wrong.
So context;
Creating a user friendly sheet to do checks on items etc. To keep it as simple as possible for other people I've decided to use drop down menus to input the majority of the data and tick boxes to say when the check has been done.
From here I want to add a big old button that will transfer the data from the cells, dropdown menu and tick boxes to another sheet or workbook.
I would also need the sheet or workbook to place the date the checks were done and create a new line with the information. So that I can look at a single sheet and see the wear and tear on the equipment in one form. (layout of this can be sorted out after wards just how to get it to go to a blank line etc.)
And finally to save the document.
drop down information is linked from another sheet within the workbook.
Now I've tried some code to work it out myself and it either doesn't copy the data as the cell is blank (drop down menus) or it just shoots up an error on the VBA page.
Could anyone assist in helping me work this code out? Even if its just the command syntax's that I would need to use.
Thanks in advance
Peter
my question is a pre-code question, as I would like to verify if and which is the best option to go about this - either formula, VBA or not possible.
I have a main workbook with an array of codes inside cells in sheet 1 - all in the format HXXX-XXX-XXX where X is numbers ranging from 0-9. Each code has an associated revision number as shown in the attached picture.
The workbook itself is named in the format: 'HXXX-XXX-XXX-YY Example Title' where YY can be any number starting from 0 to infinity (in theory). Only YY is subject to updates in the title. If changes are made in this workbook, then a new version is saved, with the YY changing in the title to the next consecutive number - Nothing else changes.
From this main workbook there are a large number of other workbooks (around 50) which share the same codes and revisions. My goal is to link all these workbooks up so that I only have to update a core main workbook and the rest of the codes (HXXX-XXX-XXX) revisions in all the other linked workbooks update accordingly.
The problem is that the other linked workbooks have a dynamic name in the format: 'HXXX-XXX-XXX-YY Example Title 2' where YY can be any number starting from 0 to infinity. YY gets updated to the next consecutive number if a change is made inside the document and this document is then saved as a separate document using Save As. NOTE: not all workbooks will get updated at the same time, as it all depends on which codes and therefore revisions are changing.
My question is firstly, is this possible with current excel functions to update links with ever-changing workbook links, which are saved as different files each time in the same folder?
Secondly, I have read about the INDIRECT function, but it is limited only to having the required workbooks opened at the same time as the updates to the main workbook, hence I am unsure that Formulas will work (I will be linking 50 workbooks to the main workbook) - From this I am gauging that VBA may be the best option, but I would like to double check this is possible before I begin attempting the code.
Of course the use of Formulas in the sheets would be much better, but because the file names are dynamic, and since the updated workbooks are saved as different files each time changes are made to it, I don't believe this is possible.
If I understand your problem correctly you need to differentiate between 3 things.
Using only Excel Formulas.
The problem with this is that formulas crossing workbooks have the big disadvantage, that you need to have the source-workbook open, otherwise manny formulas will not work correctly or update. You also have the disadvantage that saving the file needs still to be done automatically. The advantage is that you do not need VBA macros.
Using Power Query
With Power Query youmight be able to solve the problems with the dynamic names.You can even read a whole folder of files, combine them and do transformations without the need to open the files manually. But you still need to save new files manually and the files will only update once they are opened.
Using VBA
You can prettymuch do everything you asked in your problem description but VBA has its own disadvantages. Firstly the file-format ".xlsm" is not allowed by the IT department everywhere. Also to work, every user using the files needs to activate macros, otherwise the macros won't get executed. Therefore I think a VBA solution is better fitted if you only have a small circle of users or if you can execute the macros on your own (e.g. if the main workbook was updated, you need to execute a macro which opens, modifies and saves all affected files). After that you colleagues do not need VBA themself.
Possible solution:
To avoid VBA you could try to create a Power Query in each "other workbook". The query will read all filenames in the folder where the main workbook is located. Now you sort and filter for the workbook with the newest/highest ID/Titel automatically and load the result as an seperate Excel sheet (all that is possible with power query and without VBA).
Now you can use the "indirect" formula to use the ID/Titel to link to the newest main workbook. As mentioned above this will require that the main workbook is opened. Otherwise the indirect formula will not update the values. If that is out of the question, you probably need to go with VBA.
This is a good theory discussion. I have a VBA heavy workbook that pulls information from a database for a specific item. Let's pretend that that item is a sales invoice. The way the workbook works now is that there is a cell in which you put a invoice number then click a refresh button and all the information for that invoice is pulled and munged in the workbook.
Is there a way that, from a command line sorta thing, set the cell with the invoice number to a value then execute the refresh when the workbook is opened? I know that I can fire the refresh macro when the workbook open via VBA, the real question is can I set a cell value to something from outside Excel. The goal is to provide a hyperlink I build that when a user clicks it, the cell value is set then the data refreshed. I am not sure where to look for this answer.
Thank you.
From reading the link I have included below, it would appeear that you cannot pass command line parameters to excel directly, however, you can use vb script which accepts parameters and then the vb script opens excel and inserts the parameter value
Link to post on MSD
Currently we have a Excel VBA application, which consists of 25-30 Excel sheet (and all of those sheets all hidden and we do background processing on them and display it to VBA forms UI), and we have developed a UI using VB forms. But problem we are facing is whenever we click on Save button using this code:
ThisWorkbook.Save
But this saves entire workbook not an individual sheet, so even if we make changes in single sheet it saves entire workbook and this save processing makes very slow (since it needs to save all excel sheet containing lot of data unnecessary, even if there is no changes).
My question is is there any way we can save "only one sheet in a particular excel sheet" not an entire excel file?
Note: I am a Java developer and I worked on VBA before, But it was years back, and I have forgotten bit. Any guidance would be appreciated. Or any pointers on how to handle this situation would be appreciated. Please let me know if you need any more information, I can edit this question.
What I have tried already? I did a lot of research from yesterday, I searched in previous questions on SO, but didn't get any useful information. As per my research it says we cannot do this. Am I on right path?
The short answer is no. You cannot save a single worksheet at a time.
You may want to try to reduce the amount of data in the workbook. Try storing data in several workbooks and when it is needed, open that specific workbook, make the needed changes, and then close it.
If it is necessary to have access to all data at once then consider using access or some other database.
It is also possible that the sheets have "blank data". Cells that don't contain anything in them but excel thinks they do so when saving it tries to save way more than needed.
Assuming that it is the active worksheet that you want to save then you could do something like this:
ActiveSheet.Copy
ActiveWorkbook.Close True, "path"
This copies the active worksheet which creates a new workbook which will become the active workbook. Then just call the close method on that and give it a file name.
I think you should consider splitting your application into multiple workbooks:
The workbook that contains all the logic, user forms and programming code. This workbook handles all other workbooks as well as the displaying of it. Potentially, this could be even an "Application Specific Addin", that stays dormant but activates as soon as any of it's subsequent workbooks gets opened. For this architecture approach check out the section on "Application Specific Addins" in this link.
This workobook/add-in can also hide the other workbooks, so that the user will not notice it's multiple workbooks.
One or multiple data workbooks: Depending how interlinked the data is, you can separate this, e.g. in a "Sales data" workbook which contains the large database, as "Base data" workbook, that contains all the smaller data (e.g. products or stores tables).
This way, you can reduce the saving to the "relevant" sheets. However, of course this requires quite a bit of reprogramming - but it's worth the effort, as for instance it also allows to provide updates/bug fixes without having the transfer the data between versions, as you only need to distribute the the file with programming logic. :-)
I have monthly report data in separate tabs, Jan to Dec.
I took the data from Jan and linked it to a powerpoint page in order to display it for briefings. I have the layout set exactly how I want it, so I copied the slide and then wanted to edit the new slide to use the data from Feb instead of Jan, however I can't seem to update the links so they use the other sheet. It just asks me to select a new file.
The links option allows me to select a new spreadsheet file but not the same file and different sheet. Is there anyway around this?
The data embedded in the ppt is both cell data & charts.
Hopefully, I've explained what I mean well enough.
Many thanks for any help and advice. =)
Your subject mentions links but later you say "The data embedded in the ppt ..."
Linked and embedded objects are two different things with different behaviors.
If you want different slides to point to different parts of your worksheet/workbook and to update at need, you'll want to do this for each slide:
Select the data in Excel
Copy it
Switch to PowerPoint, move to the slide where you want to display the data
Choose Paste Special, then choose to Link
You could, in theory, accomplish something similar by creating one link, then copying the slide and finally editing the link target, but that'd take either an add-in or some coding, and would in any case probably be more trouble than it'd be worth.
Create a tab in the file and name it "Current" or something to that effect.
Link it to the month tab you want, like Jan.
Create the link in powerpoint how ever you have already, to this tab and not the Jan tab.
you can change the links in the tab "Current" to point to a different tab, like Mar.
Update you powerpoint by either up dating links (for pastespecial as link ) or just double click the embedded object in powerpoint while the Excel file is already open