Is there a way to dynamically reference sheet names in excel - excel

seeing the way my current question trends I don't think this one will earn a lot of merit points. admittedly, this is a "I'm lazy of doing repetitive tasks and want to automate it" kinda question
Question: is there a way to dynamically have the pivot update its target range to the active worksheet and not the last sheet you copied it from?
my goal is to get something like
=activesheet!$a$1:$b:$2
why I'm asking this question: I never really liked pivot tables, always thought they were a waste of time, but since my boss likes them and doesn't like vba, I gotta conform and use the dumb pivots.
really not sure what kind of other materials or proof of research you guys want with this question, but i did try to search on my own and found nothing. if theres anything else you guys want just ask. Thx

Can't comment, so please don't complain for putting it in here ;-)
There is something which could ease the pain when updating the data source after pasting the pivot table into a new workbook:
If the Pivot Table does not refer to a range but to an Excel table instead (cf. Ribbon -> Insert-Tab -> Table), then you will just need to remove the file name in the data source without updating the range (because there is no range, just the table name)

Related

Dynamically merge tables in Excel

I've found several sources that appear to give me a solution to my need, but each one has come up short. I think my solution is in using VBA UNION; however, I am a complete VBA noob, so I feel like I shooting in the dark. Here is my need.
I have a worksheet with multiple tabs.
Each tab has the same headers for the first 10 columns.
I'd like a sheet that is a summary of the first 10 columns of all other sheets combined.
I thought if I made each sheet a table and named each, I could create a range of ranges and then just call that combined range on the summary tab. My thought is there a solution somewhere with Union here, but I don't know enough to know if that's right or not.
I need basically what this solution is, but rather than it running on a run command and doing a copy/paste, the result just needs to dynamically update. https://danwagner.co/how-to-combine-data-from-multiple-sheets-into-a-single-sheet/
As a Google Sheets user, this is super simple, but I have to use Excel for this. I feel like there must be a simple solution that I am just completely missing. In Sheets I'd have just done ={range1;range2;range3;etc} and I'd have had my output, if that helps someone get what I need.
Any help here is very much appreciated.
Part of what is great about VBA is that it is an event-driven language, so you can set your code to run every time a cell is changed, workbook is saved, etc. instead of having to press a button. I recommend reading up to section 3.1 of Excel VBA Events - An Easy Guide where it explains how you can use:
Private Sub Worksheet_Change(ByVal Target as Range)
CombineDataFromAllSheets
End Sub

Autocompiling excel sheet from catalog

I need to create an excel sheet where the user can select many products and for each one the corrispondent row will be automatically compiled with the product info inserted in another sheet (or something that represents the product catalog). How can I do?
Thank you!
Start simpler. Given that it sounds like you are still pretty new to the features of Excel and VBA in particular, I think you may want to read up a little on some of the options before diving into so large a project.
Below are some links I found from Googling some of the topics you asked about, I hope they help:
Getting started with VBA: https://learn.microsoft.com/en-us/office/vba/library-reference/concepts/getting-started-with-vba-in-office
Creating lists in cells: https://www.youtube.com/watch?v=KGnvCKiOLM0
VBA looping through worksheets: https://support.microsoft.com/en-us/help/142126/macro-to-loop-through-all-worksheets-in-a-workbook
VBA looping through cells: https://www.youtube.com/watch?v=5bq3N99mNPE
Once you have a rudimentary project put together with some code and are stuck, bring us those specific questions that have you stuck so we can help you work through them.
Good luck!

Multiuser in excel 2010

I am new to this stackoverflow and i can say that its a very interesting and resourceful website.
I need to share a workbook on a network and as you already know the workbook must not contain any table or XML maps but i prefer to use a table because it is an expandable range. Information are extracted from this table via formulas.
Is there any work around possible to share the workbook with the table included?
I do not want to use formula for an expandable range in order to maximize the efficiency of the workbook because there are already lots of formula in the workbook.
Besides what is the maximum number of users that can access the workbook at the same time, with each user having access to only one worksheet
Thanking you in advance for your precious help.
Best Regards
Jack
Here has:
Note first and last entries in the image.
And that it was the first hit to the Google query Excel 2010 spec
so please see also the first bullet point here.

Protecting a Chart Name

Does anyone know if there is a way to protect a chart name so that the user cannot change it? I've got quite a bit of code that references various charts. If a user was to change one or more of the chart names, things would get ugly in a hurry.
I might have a solution for you, but it brings some overhead.
You could add a real chart for every chart you are using and want to have name-protected in your workbook. They appear as seperate tabs (like a table) in your workbook.
Looks like here:
Right click on your chart and select move chart then new sheet. This way you are going to have "better" chart objects, which you can protect seperately through VBA or through Ribbon-Menue AND you have an internal CodeName!
Like here:
With an internal CodeName your user-troubles should be done with, because they can name them how they want and so can you ;) I don't trust indexes eighter and hate using user defined names - code names are the best, except for handling in code, but that is just a major vba flaw.
I'll guess, that those additional charts will however anoy you a bit, so just make them invisible and use copies of them as ChartObjects in your tables.
This should be it.
Further I stumbled uppon the interesting fact, that you really only can protect the chartname by protecting it as a nested object in a protected table. Even with my attempt users would be able to change the name, unless you protect the workbook-structure and all table/chart names with it.
Hope this helps ;)
Try something like this code. Change "Sheet1" to "Chart#". Also the last little bit (commented out & Workbook.Sheets.Count) can be added back in to your coding to add a incremental naming if you have many charts as you noted.
ThisWorkbook.VBProject.VBComponents(Sheets("Sheet2").CodeName).Name = "NewChartName" ' & Workbook.Sheets.Count

Create a new sheet for each row

In an Excel sheet, I have roughly 30 rows x 100 columns of data. Each row represents a different "client". For each client, I've create a summary sheet that is emailed to them and that also contains all the information from my main sheet
Is there a way for Excel to create a new sheet based on some template sheet when I add a new row to my main sheet and fill it with the appropriate data?
I will give you my opinion about your need, the way I see it, at least. It is not a "ready to use" solution, however, only some ideas about the way to do that.
From what I know, there is no way to track insertion of a row in Excel. So you would require a VBA function to be activated on a button, for example. Actually, there is, see Lunatik's answer.
This function would loop over all rows in your main sheet, and create a new sheet when necessary (you would need preferably a unique id for each client, it could be a simple index on the main sheet, depending on the line).
You would create at first your template sheet, with a specific name, and eventually hide it (to not have it in the visible tabs). When I say that the function would create, it would in fact copy this template sheet and give it a unique name (the id I mentioned earlier). You can find ways to copy sheets at this link.
A second operation to do, would be to put data from the row in the main sheet, to the template sheet (if I understood correctly your requirement), which is not really complicated to do in VBA.
If you need this to happen automatically on the addition of a row then you would need to use the Worksheet_Change event to capture the completion of a new row.
This would then generate a new workbook from the template, copy across the necessary ranges then save the new file somewhere, much as Gnoupi says
All this is relatively trivial with VBA, but unfortunately if you aren't familiar with VBA then isn't a simple case of "Do X then do Y in Excel" so I think you may struggle, even with sample code posted here.
Even if I created a dummy model that did what you require, functionally at least, then customising it to your particular needs may difficult if you are not used to working with Excel programmatically.
Edit
I've created a very simple demonstration of how this could work: http://drop.io/4clxof3 - note this example doesn't include the event handling for adding a new row, has almost no validation or error handling and makes sweeping assumptions about almost everything(!)
If you feel comfortable using this a basis for developing your own solution then great. If the whole VBA thing is foreign to you then it may be time to call in reinforcements :)
i was wondering if it was possible with no error catching. Simply just have a VBA code that takes each row of the Excel Document - Creates a file for each row and then at the end combines the total files in a folder into one?
I know sounds weird.. but is this possible?

Resources