VBA - Importing Data from Multiple Workbooks - excel

I am not looking for help with any specific vba coding, just peoples ideas on the best approach to handle a couple of scenarios. The solution has to work with Excel 2007 onwards (can not use Get & Transform / Power Query). In both cases the idea is to have a Master document in to which raw data is updated each week. It should not be necessary to manually redefine any of the formulas or references in the Master document after the update process in order to summarise / analyse the data.
Scenario 1 : Weekly sales figures for various products received from six different retail outlets in the form of an .xlsx file. The data is contained on one sheet in each file. Although the product lists are the same the layout of the data from each outlet is different and a 'standard' template will not be introduced. The user needs the ability to manually select each file to include in the update. The data from each outlet needs to be combined in the 'Master' document for additional processing etc.
What would be the best way to automate the Master document update process?
Possible idea : in the Master spreadhseet create an MS Query for each outlet to import the data from each outlet in to separate sheets in the Master spreadsheet. For each outlet the user would be prompted to identify the file and its location using Application.FileDialog(msoFileDialogOpen) and the response used to modify the connection string prior to running the Query to retrieve the latest information.
Scenario 2 : Multiple workbooks received each week (80+) containing employee time and attendance data. The workbooks are saved in a single folder. The layout and format of the workbooks is the same with the data presented on one sheet in each. The data needs to be combined in the Master document for analysis.
What would be the best approach to allow the user to identify the workbooks and the transfer the data from these in to the Master spreadsheet for processing. Can not use the 'From Folder' in Get & Transform as it must work in Excel 2007 upwards.
Thanks

What would be the best approach to allow the user to identify the workbooks and the transfer the data from these in to the Master spreadsheet for processing? I think you need to hook into this AddIn, as described below, and all your questions will be answered.
https://www.rondebruin.nl/win/addins/rdbmerge.htm

Related

What is the best way to work with manually Excel collected data from different sources?

I have been tasked with creating Power BI KPI reports and the data to feed those reports comes from different sources and is collected manually.
There is one person responsible per KPI. That person collects the KPI's data monthly and puts it in an Excel file. Then, that person sends the xlsm file to another person, who is responsible of organizing multiple KPI's into one Excel file. Ultimately, that person sends it to me and I use that xlsm file to create the report. The same process goes on per area of the company (6 in total) every month.
As you can see, there is a lot of copy/paste going on which can indice errors.
What is the best way to approach this?
I can't comment, so I will explain here what I think you can do.
I will ignore the collecting of data by person responsible per KPI.
You can use a database connection, using plugins or VBA, to send the Excel data to a database. Create a VBA Excel file with a script to send the data to a database and there you can do whatever you want. The most important thing that you need to do, is limit the 'columns' of data that Excel will have, or find a way to get the data directly from the source, using an API or whatever you find.
Another approach is creating a web form to send data directly to you, but i don't know if this is possible in your case.
It's the only thing I can think, given the limited options.

Multiple "Views" of the same table in excel

I am currently managing invoice payments in Excel and was wondering if there is any way to create multiple editable tables that display the exact same (synchronized) data.
Essentially, I want multiple filters active on the same table at once so I can (for example) open up all transfers from a single creditor to the right one side of my screen, while looking through all bank statements on the other (while being able to edit the data in both tables).
I have looked into excel Data Models but I am not sure if what I am asking for is possible.
Excel allows you to view two windows of the same sheet. Give this a try. https://www.excelcampus.com/tips/new-window/

How to search across multiple excels for values and summarize to one excel workbook

I have 1000 excel workbooks and I have to summarize data in one excel workbook. Each workbook consists of data of one property (id of property, region, market value etc.) In the summary workbook I want to insert in a column the id of property and automatically search across the file of workbooks and insert the value for its region, market value etc.
Thanks
I am going to first assume that there is some structure to the workbooks you are discussing, for example all market value workbooks are the same but only the data is different. it would also be great if they were in different folders and if they were named in a consistent way.
This is only an example with links to different content that will help solve your problem. Your question is too vague and does not provide me with specific enough information to provide exact solution.
Combining records.
https://www.youtube.com/watch?v=rSQwZ1d3b1g&list=PLrRPvpgDmw0m3ohSvgwoHvd0KO8QsQdiK&index=5&t=0s
Merge Records.
https://www.youtube.com/watch?v=8F7v6YvnsiY&list=PLrRPvpgDmw0m3ohSvgwoHvd0KO8QsQdiK&index=6
Pivot Table Slicer for summary reports.
https://www.youtube.com/watch?v=zgt7SdrYJqg
Your best bet would be to use the power query feature to combine data from workbooks inside a folder
From DATA TAB -> Select GET DATA drop down from Get & Transform ribbon -> From File -> From Folder.
You should be able to combine all the workbooks in folder If your problem is simple.
If each workbook has multiple pages of info and the pages differ then you will need to create a custom function in power query to handle this issue.
If workbooks are all in one folder then you will need to run power query multiple times per condition and use a filter with power query assuming that the files have some kind of organized naming convention.
Once you have combined files and cleaned up the data you should be able to combine the records.
You will do this using the power query feature merge feature.
From DATA TAB -> Select GET DATA drop down from Get & Transform ribbon -> Combine Queries -> Merge.
Once records are all merged you should be able to have your final table and use a pivot table to give you the option to select ID with filters or pivot table slicers so that you can have the summary report by ID going across all the workbooks like you wanted.
If anything is unclear please provide more info so i can help you specifically

Copy and paste Excel rows between two workbooks based on criteria from exported Access data

I have no previous experience in Access, VBA coding or in Excel macros prior to teaching myself the past month via these forums. Thank you forums and contributors. I have enjoyed my Access learnings so far, the challenge that it has provided and appreciate any help that I can get. As such, the code and methods that I have used to this point may well be convoluted and confusing. I will do my best to provide relevant details and accurate terminology.
I work in a lab and I am creating an Access Form for semi-automated reporting. Samples are received from clients and are logged into the Excel Table R&D Log. The worksheet is InProcess. Samples are sorted based on the site in which they originate and given a one or two letter site code (G, D, WH, etc.) and an ID "yy-000" in separate Excel columns (i.e. D 18-096). Samples may be submitted for multiple analyses (Metals, Water, Soil, etc.) and may even have multiple rows of reporting if multiple analytes are identified in the sample. There are several other columns, such as receipt date, reporting date, units, etc. Once samples are reported, I manually copy and paste them into the Archived worksheet, and delete the record and blank row from the InProcess worksheet. Since one sample may have multiple analyses and even more potential results, each record would be reported on a new Excel row (with the same D 18-096 ID number). Thus, there is not a single unique identifier or primary key for each sample in the current format. R&D Log is updated manually by lab technicians and the worksheet InProcess is a linked table in an Access Database.
The Access Database is using two combo boxes on a Form frmInProcess to filter a Query qryInProcess of the linked table. The combo boxes are filtering the report destination (one client may receive multiple site codes) and the analysis (reports are separated based on type of analysis). The Query is also filtering out blank results and blank dates, so only completed samples will appear on the filtered Form. I have generated VBA code to this point that will export the Form to a .pdf, save the file with unique filename, and open outlook to mail out the report. I have also managed to export the filtered Form frmInProcess to an Excel file Access Test (not the linked file).
What I would like to do now is to automate the transfer of completed test results from the Excel worksheet R&D Log: InProcess to R&D Log: Archived and delete the record from the InProcess worksheet. I am not sure if I can export the filtered Form into a linked Excel table, or if I must use a separate Excel file (or if it even matters for simplicity of code?). I would now like to read the exported filtered Form in Excel Access Test, lookup matching rows in R&D Log based on several criteria (site, ID, Analysis, Analyte, Report Date) and automate the transfer of records between R&D Log worksheets. End result being that Access generates reports for completed tests, and the records are removed from InProcess testing and transferred to Archived testing in Excel. I am guessing that I may need to close the Access application and perform this in Excel. Hope this is easy enough to follow.
Thank you.
In my experience, importing an Excel document into a temporary NEW (or totally empty) Access table is usually the easiest way to go. Then you do not have to worry about cell references like you do in Excel VBA. Even if the Excel document has old data in it with just a few new changes each time, importing it into a temporary Access table could be the simplest way to go, because then you can compare the data in this table with the data in another, permanent Access table and update the latter based on the former.
As far as the original Excel file, if you need to delete rows there, it might be quicker to export a new Excel file with just the data the old one is supposed to end up with, and then use VBA to delete (or - safer! - rename) the old file.
So the development process goes something like this:
Save import steps by first importing an Excel file via Access' ribbon options "External Data" (tab) ->"Excel" and when you finish, be sure to check the "Save import steps" box and note the name you give the "saved import" because you will need that in your VBA code.
In Access, write a function for deleting the table. The VBA code is:
Const cTable = "MyExcelTempTable"
If TableExists(cTable) Then
DoCmd.DeleteObject acTable, cTable
End If
Now you can test your delete function on the data you imported.
Write VBA code to import the same spreadsheet to create the same table:
Const cSavedImport = "Import-MyExcelTempTable"
' Import the Excel file
DoCmd.RunSavedImportExport cSavedImport
Write more VBA function(s) to check the imported table for bad data and then to copy it into the permanent table. You might be updating existing records or adding new ones. Either way, you could use Access queries or SQL to do this and run them from VBA.
Write a VBA function to rename the old Excel file. (You could use an InputBox if the Excel file name is different each time. I do this for importing Excel files, and I set a default value so I do not have to type as much.)
Write a VBA function to export the new version of the Excel file.
Make yourself a button on a form that, when clicked, runs a VBA function. Inside that function, run Steps 2 through 6, above.
I am not sure my answer exactly matches what you are trying to do, but hopefully you get enough of a picture of the workflow to figure out the details of what you need.

Easily Update Master Spreadsheet from Various Spreadsheets

I have a master spreadsheet that we use for tracking a certain activity. The spreadsheet contains various lines with item descriptions, and open columns where end users are to fill in dates.
An updated master spreadsheet goes out to various end users to update date values and return it to the coordinator. The coordinator then takes the various feedback sheets, and updates the master accordingly.
Up to now, this has been quite a labor-intensive task as end-users change filtering settings before sending it back, and there are 1000+ lines, so it is hard to see what the end-users updated.
Does someone know of an effective method to do a task like this, using Excel directly or VBA?
I would recommend creating a server version of the master spreadsheet so that end-users could check out that document,fill in their dates and avoid the redundancy of having someone retype everything. Sharepoint's ideal for this kind of thing.
If you want to keep it to Excel alone, though, perhaps you could save all the modified user-input-provided workbooks to a designated folder. Then write a macro to loop through each of these files in the folder. Supposing that the cells the users fill/inputting data into were previously empty, check to see if they're now not empty and copy those changes to the master file.

Resources