Comparing data between two sheets in Powershell - how to find data after cells with specific values? - excel

To start, unfortunately I cannot use Import-Excel (yet! organization is looking to implement the module "soon") or other outside modules, so am just working with excel objects manually.
I made an automated report that appends to an excel document every day. It looks something like the included picture. The servers and their data are not in the same cell position for each daily sheet, but are always grouped together (so Server1 and its data might be in the middle of today's sheet, but at the beginning yesterdays sheet). Databases can change, so I'll also be looking into error checking that a database actually exists on both sheets to compare them.
I want to check the most recent sheet (sheet labeled 2020-08-10) and compare each database with the same databases on the oldest sheet (sheet labeled 2020-08-08) to get a size % difference between each database, but I can't seem to figure out how to automate finding the multiple "Database" rows of each server, then going down and grabbing each database and size to compare.
Any help or guidance to get me researching in the right direction is appreciated.

Related

Create Connection to one raw data file for multiple excel files

I currently have one excel file with four worksheets with data (Name: target value 2022.xlsx). This data is used in multiple excel files to make calculations and to show the values using VLookUp. Until now I copy-paste the values from this one file with four worksheets into all the other files with those four worksheets (and more) when one value changes throughout the year. It also seems to be problematic when a new year begins and a new "target value 2023.xlsx" is required. I tested a lot of ways to make a connection, but nothing seems to be the perfect way:
copy-paste each table via VBA (current way, but I don't want to open every file just because one value changed and click the "Refresh" button)
external reference Cell A1: =[target value 2022.xlsx]Table1!E3 (if one column is deleted, the connection shows #REF!)
Data > New Query > From File > From Workbook (if one column is deleted, the power query doesn't work anymore)
Data > From Text (only works, if all four worksheets are in four seperate csv-files, not optimal)
Data > From Access (seems to be the best way to get the data from four different tables within the database???)
What's the best way to do this, if multiple people use it? The values in "target value 2022.xlsx" change multiple times a year and many users need different files where the data is required. Thank you!

Check For Matches And Import Data Into Specific Cells From An External Source

We are trying to track some online marketing metrics and I'm having some trouble. I have 2 tables in different tabs (one imports data from several external data sources, ultimately we want this to be a series of google sheets) and one is the working table.
I have rows on the imported data with month and other attributes defining the data and in the working data these are columns. The working data has a lot of other cells too that are not there with calculations, etc.
What I need to do is to check on the working sheet which month (for example) we are in, then go to the working data and scan all the data for matches with that month. Then I want to consolidate each of the data parameters into the working sheet. Ideally I wouldn't even have to import all the external data into a tab on the working spreadsheet, if I could find a way to work where it would check the external documents for the matches that would be great. The structure of the data in the external documents is the same as displayed here fore the imported data.
Note that in this case it is month but it could be anything random so DATE functions wouldn't work.
So I want to pickup the data from the external source above, and insert in the relevant places. But while the months will not change, other data can change the order in which is imported so we need to check that the headers from picture 2 match the row labels from the imported data.
I hope that makes sense. I would really appreciate any help. Was up until 4 AM trying to figure this out and I would hate to go back to my boss saying he's gonna need to get someone else to do this as I can't. :/
Thank you.
So I resolved this with a INDEX(array, MATCH(),MATCH()) function. First I selected the answer array from the cells with the info I wanted then used the MATCH Function to match the row and the columns I wanted in the matrix.
This created another problem where no answer existed as it threw an error so I had to envelop the whole expression in an IFERROR function.
The final solution was like this:
=IFERROR(INDEX(Table_Query_from_Excel_Files,MATCH(!H1:I1&A1,INDEX(Table_Query_from_Excel_Files[Month]&Table_Query_from_Excel_Files[User location],,),0),MATCH(!A1,Table_Query_from_Excel_Files[#Headers],0)), 0)

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.

If vloopup Return Values Query

Ok this is a tad complicated to explain and im guessing even harder to solve. Im trying to automate a debtor's list at my work so we don't have to manually change it every week which can take hours. Currently we have one master file that contains all amounts owed to us and another that lists all outstanding amounts and any information on that client relevant to the invoice.
The master file is automated from a CSV file however i am attempting to integrate the overdue list into this and make it automated as possible. This issue im having is if i automate the debtors list then any comments i have are also erased
Client-----Invoice #-----Amount-----Comment
X----------1-------------400--------Will not pay until (###)
Y----------2-------------500--------Having an issue with designs
Z----------3-------------600--------Something
What happens when i automate this is that the comments remain however all the other columns are replaced with the current data which messes the entries up. Essentially what i thought to do is the following however im not sure how to implement it.
Have the master debtor list on one worksheet and another sheet for the debtor's and comments
Using a formula the 2nd sheet will extract values from the master sheet based on the following:
If the invoice number is on the master list and not the 2nd sheet then all information will be copied to the 2nd sheet.
If the invoice number is on the master list and the 2nd sheet nothing will be done
If the invoice number is on the 2nd sheet but not on the master list the information will be deleted
I basically want the information to be retrieved if it isn't there, deleted if it isn't on the master list and left alone if it is on both already. This will therefore let people add comments but automatically delete once payment has been recorded.
Any help would be fantastic as ive tried a huge amount of If, vlookup, match etc and can't seem to get the result id like.

Create new sheets based on roster and auto calculate completes

Okay, Im setting up a spreadsheet that will track employee progress. Im new to vba and macro programming in excel but am not foreign to programing in general. Any assistance would be greatly appreciated. What I want to do is as follows.
Start off with 3 sheets (roster, log, Total) The log sheet will have all the tracking metrics of each employee.Total will Total each employees log sheet together and roster will be a dynamic employee list. As a new entry is created in roster then I want to copy the log sheet and rename it by the name put into roster and add the new (named) sheet into the Totals calculations.
For arguments sake just say that each log sheet only has a numerical value in a1 and total is just tallying all log sheets a1 fields. Roster contains just a first name in column A and no other data. (Given direction I should be able to expand the concept to a more intricate set of sheets.
Additionally it would be interesting to be able to remove a name from roster and have the said log sheet be deleted and removed from the totals formula... :D
Again Thanks for any assistance.
I have seen people try to make excel work like a database and it is ultimately doomed to failure. As this is a green field project I would start it right and use some sort of database. The choice is yours depending on your skillset, hardware available and what it will be used for. A good starting point would be good old MS Access, it is quick to learn and in the right hands very powerful. If it is going to be higher use then maybe look to a server based data store such as SQL server and write the front end in anything you want (Access, vb.net, asp.net etc)
The point here is choosing the right tool for the right job, spreadsheets have their place but databases they are not

Resources