Copy & Paste From Different Workbooks to MasterSheet - excel

I have one workbook with 8 sheets per country (i.e. France, Belgium, etc.). Apart from these sheets I have "Mastertab" and "Database".
Country-sheets are created in the same way (they have the same template). These templates are made to track expenses (therefore for example, France may have 10 expenses, Belgium 3 and UK 81).
What I would like to do is to create a macro (because I think it is impossible with formula if I want to avoid blank rows) that will:
Find last row where is any data/value in column K.
Select all data (row that will be indicated in point 1 and columns B-P).
Paste this selection to the Mastertab.
Continue doing 1-3 for other countries/sheets KNOWING that data should be pasted just below the previous one (so it has to find first blank row and paste data there).
Example:
First row with data for each country is 18. This is the place where first line with expense is posted. User will fill in only data in column K (all other columns are filled with formulas, vlookups, etc.)
Assuming that I have 3 expenses for France, I want Excel to select B18:P20 and paste into Mastersheet in cell B18.*
*Next pasting in Mastersheet should be from cell B21.
Hope it is clear. :)
Thank you in advance,
Marek

you would definitely be stretching the limitations of Excel formulas if you tried using formulas to do this.
You can use VBA to do this, but you're going to probably going to need the user to trigger the macro every time they make an entry. If you need the master to be dynamically updated then that's going to be harder again.
I think the cleanest way to do this is to have a macro that builds the master list from scratch every time you run the macro, i.e. deletes the Master sheet, and recreates it again. This way you don't have to deal with reorganizing the master output every time a new row is added. That would require a lot of additional logic.
If you are doing a multi-user environment with concurrent updates, then this approach will not work, as you would need an additional server to handle messaging between each user. At this point, you're better off not using Excel.
If each user will add their data, run the macro and send the sheet to the next user you could concoct a macro approach.
From a very high level:
Create a macro to co-ordinate all that comes below
Delete everything in your master (MasterSheetName.Cells.ClearContents will keep the formats if you need it)
Create an index which keeps track of the last row with data in your master sheet. This will start at 1
Iterate through each of the country sheets
https://support.microsoft.com/en-ie/help/142126/macro-to-loop-through-all-worksheets-in-a-workbook
Iterate through column K looking for values
Iterating through populated rows in Excel using VBA
In this example they are looking at column A. You can replace 1 in the sh.Cells(row,1) to sh.Cells(row,11)
Copy the data to the mastertab
Copy from one workbook and paste into another

Related

Copying rows from one sheet to another - checking previously copied data and inserting data above row that says "Subtotal" in column G

A bit of background before I start. Essentially, I've got all workers to fill out a form of their 'whereabouts' and what work they did, this then automatically populates into the correct fields etc. Using Power Automate, however, this is in table format and will literally update a a type of master.
My answer to this has been to just pull every cell from the Master table (e.g =A1 of x sheet) that my Power Automate flow creates and just bring it onto a centralised spreadsheet. Then from my forms submission there is a unique reference for form submission in cell G on every row, which will be the time and date they submit their response.
My data all has formulas in (as explained above), therefore the last row will be pretty difficult to find as I can't just find the last row as I usually would - so this would usually just go to the last cell where there aren't formulas, right?
How would I be able to find the correct rows to copy over?
Ideally, I would check to see the values value in column G that appears in any other sheet, if they do, do not copy. If they don't then copy over and insert rows above the cell which contains the text 'Sub Total'
Not sure if I've just fully confused myself and it's super easy but I just can't figure it out and even get started on it.
I am struggling to even think of a solution, apologies.

skip if statement is false in excel mac

I am currently working on a database (that's why I needed to blur some cells.) and I want to copy some data from the first sheet according to the graduation status. We are planning to use this database for next years too, so I want it to copy the data automatically when someone adds information. I wrote a formula for this, it is copying the data as I want but it cant skip the false condition; as it can be seen, the 8-9-16-17th row in General Sheet is copied to Student Sheet.
I saw another problem like mine and tried to implement the formula in my sheet but I couldn't make it work.
The problem that another person was dealing with: Get cell value but skip row if wrong
The formula I found and tried to implement in my Excel book: =IFERROR(SMALL(IF(($B$2:$B$15="Denied"),$A$2:$A$15,""),ROW()-2),"")
The formula I used in my Excel book: =IF(GENERAL!E3 = "Student";Table1[#Name];"")
With Excel 365 you can use the Filter() function. In the sreenshot I used
=FILTER(A:C,B:B="student")
Be aware, though, that with any formula solution, the result will be dynamically recalculated, so if you are planning on adding any data to the filtered table, these manual data entries will become a problem when the formula updates and the previous results occupy different positions.
If your goal is to get a one-time copy of all the non-graduated Students in Sheet A, you could just sort the sheet by the status column and copy/paste the desired data into a new sheet. That pasted data will not change and you can make manual edits.

Data consolidation using Columns

We sell our product via a number of different retailers. These shops send us reports of what they have sold and we need to import this into our new stock management system as a master file.
The stores do not and will not provide the data in a uniform way based on our desired template.
I therefore need a way of consolidating ranges of data that without having a unique ID for each line, with minimal manual formatting from the data importer to help save time.
http://s14.postimg.org/arslbnnxt/excelconsolidation.jpg
As you can see in the 2 examples above, nothing is in the same order and some of the supplied fields haven't been used. The column headers are static, only the data is actually pasted.
I've tried using the Excel Data consolidation tool but the SUM function just wants to add everything up or simply reports a single value, I've played with Vlookup but I then need to dedicate a number of rows to each store which results in lots of empty rows.
If you can point me in the right direction I'm more than happy to research the tool or function I need, web searches keep bringing me back to the consolidation tool.
Many thanks,
Since you say that column headers are static, you actually do have a unique ID.
The task can be accomplished by using HLOOKUP with Column headers as lookup value.
However, the formula will depend on how you organize or store input sheets from different stores.
Here I have tested a setup where each store input is pasted in consecutive sheets starting from 'Sheet1'. i.e. Store1 in Sheet1, store2 in Sheet2 ... with row 1 containing header.
Then in consolidated sheet using helper columns for identifying sheet and row number, the formulas look like this
in A2 =IFERROR(HLOOKUP(A$1,INDIRECT("Sheet"&$H2&"!A:O"),$I2,0),"")
in H3 =IFERROR(IF(INDIRECT("Sheet"&H2&"!A"&I2+1)="",H2+1,H2),"") (if no more records, increment sheet number)
in I3 =IFERROR(IF((H3-H2)=0,I2+1,2),"") (if sheet number changed, reset row number to 2)
Initial value for H2 = 1 , I2 = 2
Test file: Storefile

Excel 2010 add and delete rows is very slow but calculations is not

Help!
I have an 8MB 2010 .xslx workbook (no macros) that runs a full calc in about 2 seconds. It only 2 worksheets each with less than 1,500 rows. However, it has 100 and 200 columns. It takes 20+ seconds to insert or delete a row (and much much longer when I delete a group of rows).
It does have a fair amount of calculations in the workbook largely made up of index/match formulas. I went a process to simplify that process by only calculating the matches (for the most part) at the top and left of the worksheet. For example, All of F7:DV7 will point to only 2 rows on worksheet 2 so the match() is only done once in column C and D.
I realize index/match is more complicated than simple a+b and that excel likes rows more than columns but this file isn't that big at all and it seems like it should be able to handle it. And the fact that the calculation is fine, it's just when I add/delete rows that it's so slow has me bewildered.
I came across a similar issue recently, and I found this question while searching for an answer online. Unfortunately, it didn't include an answer, so I moved on. However, I found the reason why the worksheet I was working on was taking so long to delete rows and wanted to return to this question and add my 2 cents.
In my case, it turned out one of the vlookup formulas included table array written something as SheetName!$A$1:D5000. When the formula was copied down, the range expanded by one in every cell down. So the next cell down had defined table array as SheetName!$A$1:D5001. And this went on for a few thousand rows. Turning off automatic calculation had no effect on reducing the wait whenever deleting rows.
Anyway, changing the table array in the vlookup to SheetName!A:D and copying that vlookup down the column did the trick. You didn't mention you used a vlookup, but it could be happening in the index/match formulas.
this is an areas problem. When you filter your data and select an entire column, you are selecting multiple non contiguos ranges, i.e multiple areas. A workaround could be:
sort your data from a to z to group the rows you want to delete in
only one area
Filter the values you want to delete
Delte rows
Enjoy!
If the actual order of your data is important to you, just add a column, fill it with numbers from 1 to n. Perform steps 1) 2) and 3), then restore the original order. Perform step 3).

Get unique sheet from 2 separate sheets

I have a single Excel document with 2 sheets. The first sheet contains "active" clients and the 2nd "inactive clients" but we want to merge both into a 3rd sheet "all clients". We want to ensure that there isn't any multiple rows. Column A in both sheets is the "identifier" which is a 16 digit numeric value. Both sheets have the same columns so effectively I want to match column A in both sheets and return the entire row if it's not found yet. There is around 1.2 million rows combined in both sheets, hence why I cannot just copy and paste them into a single document.
How would I go about doing this?
Good advice in the comments but because even after removal of duplicates there may not be enough rows to accommodate the de-duped list I would suggest starting by determining how many duplicates and deciding which list to delete any from (or you might end up with an incomplete combined list but no practical way to extend it). In both sheets add a column with:
=MATCH(A1,Sheet2/1!A:A,0)
(Sheet2 name for one, Sheet1 name for the other) and copy down to suit.
Then check the de-duped combination number less than 1,048,576 in total. If more they won't fit on a single sheet without an additional set of columns and even if less a database is to be preferred, though not obligatory, with the Excel version possibly convenient for upload.

Resources