Autocompiling excel sheet from catalog - excel

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!

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

Merge data from 600+ Excel worksheets and 1 Google doc

I have around 30 Excel spreadsheets, each with 20+ worksheets. Each of these worksheets follows the same basic format, though there are slight differences. I also have a Google doc with sections that match each of the worksheets.
Somehow I need to merge the data from the spreadsheets and the Google doc into a single, searchable, editable document, which will become the new safe source, eliminating the need to maintain 600+ worksheets.
So far, the plan is to have an intern copy/paste from Excel into the appropriate section in the Google doc, but besides being akin to torture, I'm afraid this approach will take days.
Can anyone think of a way to automate at least some of this?
I've been thinking that if I could somehow take all of the Excel data and migrate it into either Microsoft Word or a Google Doc, that would be a good first step.
I have used Google Apps Script in the past and could probably figure out how to write a macro in Excel, but I can't wrap my head around how I would actually accomplish what I need to do.
I'd appreciate any suggestions.
Wanted to provide an update in case anyone else ever has a similar problem...
I ended up moving all of the existing spreadsheets to Google Drive and using Google Apps Script to iterate through the folder to get the name and id of each file and then iterate through all worksheets of each of those spreadsheets, copy all data from each sheet and append it to a new master spreadsheet.
I then migrated the existing Google Doc to a Google Sheet so I could sort.
After that I manually copied the applicable sections from this Google Sheet into the correct, corresponding section of the master spreadsheet. I'm sure someone smarter than me would have been able to script that last part as well, but I was having trouble figuring out the logic and decided to brute force the last step.

Is there a way to dynamically reference sheet names in 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)

Referencing a linked file from INDEX() in Excel (Office 365)

I've got a collection of about 40 Excel worksheets. They store information about the number of hours that people have spent working on different projects, with dates across the top row from left to right and project names down the first column. Each member of the team has their own separate worksheet.
I'm making a new worksheet that will add up the number of hours each person has spent on a specific project.
I'm using this formula to add up all the numbers in a particular range of a linked file:
SUM(INDEX('S:\path\to\folder[Username_2017.xlsx]Daily'!G:JG,JOB_ROW,0))
JOB_ROW is the row containing the numbers I want to add up. Columns G:JG cover 1 Jan - 31 Dec. Username_2017.xlsx is different for each of the 40 people.
The problem is that the formula only works if I create it by hand. I can't find any way to use a dynamic reference to the filename, which gets very tedious with 40+ files to reference. I thought this might work:
SUM(INDEX(INDIRECT(C3),JOB_ROW,0))
...where C3, C4, C5 etc. would contain automatically-generated filenames and references. But it doesn't work. I get #REF!. And Excel doesn't prompt me to link the files -- which suggests to me that it will never work this way.
I've also found that even when the spreadsheet is working properly with the manually-entered formulae, if I save it and re-open it then Excel tries to be helpful by stripping out the formulas and replacing them with the text #REF!.
Is it possible to do what I'm trying to do? Or do I need to learn some VBA?
I should point out that I've largely avoided using Excel in my career so far -- so if there's a better way to achieve this then I'd love to hear it.
Thanks in advance for your help.
ian0411 gave the simple answer to this question in the comments above: the answer is "you can't do that".
If he wants to post that then I'll accept it as an answer -- but for the benefit of anyone else reading this question and looking for alternative options, here's what I tried and what worked:
VBA
I wrote some very simple VBA using GetObject() to open and read from each of the workbooks. It worked, but a) it was very slow, and b) it seemed to keep all the files open as long as Excel was running, which caused other problems. It also crashed a lot.
I gave up on VBA.
Automating the filename replacement
The next option I tried was to have a column of filenames in Excel, with a column next to it containing the formula that I wanted to run on each file. Instead of putting the linked filename in the formula, I put a unique placeholder ('XXXXX' or whatever).
Then I made a little macro that (for the currently selected row) did a search and replace across the row to change 'XXXXX' to the filename in column A. I had to run the macro 40 times to cover each file, but I only had to do that process once. When I add a new file to the list, I'll just add a new line, copy the formulas, and update the filename.
I've now got a spreadsheet which works perfectly when the linked files are closed, and which doesn't rely on VBA.
Perhaps if my VBA skills were better I could have written something less flaky -- but doing it all with INDEX() seems like the fastest, most elegant, and most reliable solution.

What is the easiest way to automate Excel tasks

If I need to automate a series a task on an excel sheet like
remove all rows where column 3 contains value "asdf"
remove column 7 and column 9
sort according to column 4
etc.
What is the easiest way of automating such tasks in excel? I think it would recording a macro but sometimes macro have to be edited a lot to actually make them work and even then macros stop if the excel sheet has a variation. Editing macro scripts could be a time taking process which becomes inefficient for such tasks. The automation is required since number of excel sheets will be a lot. Can you suggest an easier way ?
As long as, you have the activities defined - Macro is still the better thing to look for.
There could be some things that could change.
Please explain the problem with the help of code.
If you have defined the steps with a few variables, it should be easy to write a macro that wouldn't stop in case of variation.
Please post the code and describe in detail what you would want? which point does it stop, in case of variation? What would you like the code to do?
EDIT: Alternatively, you can write code in VB6/.net (c#/vb.net)/Python for automation.
If you record these steps using the macro recorder it will work fine, these are the ideal types of things for the macro recorder as the parameters (i.e. your sort by and delete conditions) are always the same. Just make sure that you always import/paste the data to the same place!
Thanks
Ross

Resources