Need some advice, I have a large excel sheet that I need to break up by a value in column B. The kicker is in some cases i need more then one value from column B. Example I might want A and B together and C on its own. I have another workbook that has this mapping. I'm stuck on 1 Best tool for this job and 2 how.
In Excel im not sure how to make this work. I know i'll need a loop to go through the list, but how do i handle the ones that need to be combined?
In access I was thinking a table for the data and a table for my package list. The create a query and loop the values into the query using VBA.
I assume you want to break your main sheet to multiple sheets based on value in column B.
You can make use of excel vba dictionary
Does VBA have Dictionary Structure?
You need to load the workbook that has the mapping into the dictionary as below:
Key = 'value in column B'
Value = 'name of the sheet where you want that data to go'
Loop through the sheet containing the data get the value in column B, lookup in the dictionary to get the sheet name to which this data should go. Write the data into that sheet name.
Hope this helps.
Related
While I am a longtime 'lurker' and have gleaned a great amount of Excel knowledge through this site, I've never asked a question before. This time I'm really stumped...
I have a table with multiple columns. The data I'm working with is obtained from a multiple VLOOKUPs of another workbook for which I do not own. That workbook has some issues with hidden characters and rows that are hidden. I'm trying to create a dashboard from this data and was successful using the AGGREGATE function (2,7) to COUNT and omit the data I don't want.
The next tier for this data needs to incorporate a lookup against another column (image attached). For this, I want to look up data in column B and subtract cells in column C if the data in column B matches a cell in column A.
I have tried multiple ways of doing this but I think that AGGREGATE might be the best approach since it can ignore hidden data and rows.
My latest attempt was to add an IF statement as follows, but that results in a SPILL condition:
=IF('Transport Calendar'!E2:E830='Transport Calcs'!M6,AGGREGATE(2,7,'Transport Calendar'!X2:X830)-AGGREGATE(2,7,'Transport Calendar'!Z2:Z830),"FALSE")
Any help would most certainly be appreciated!
This is probably a very trivial question for an Excel expert, so I apologize in advance. I spent hours on this, but as everything in Excel -- unless one is an expert in it they will probably find quantum physics easier.
I have a workbook with a sheet which needs to pull data from another sheet. There are two lookup criteria:
A row-based lookup on the other sheet, which is working and finding the corresponding row.
In the corresponding row on the other sheet, I need to grab a value from a cell in that row based on a dynamic column name. So I have a string-based name of the column (i.e. the header; i.e. row #1), and I need to grab the value from the it based on the column's name.
Here is my lookup code and what I am trying to do:
=XLOOKUP(
// Source data for row lookup (working)
D3&H3,
// Destination data for row lookup on other sheet (working)
'Prices'!$A$2:$A$1048576 & 'Prices'!$B$2:$B$1048576,
// Not real code, but the part that I am trying to accomplish.
// The CUSTOM_COLUMN_NAME will come from either a formula or
// another cell on the given sheet, and is supposed to denote
// the column header name on the Prices sheet.
'Prices'["CUSTOM_COLUMN_NAME"]:$2$1048576
)
(I provided the entire function just in case it would be easier for someone to rewrite it with VLOOKUP or HLOOKUP)
Hopefully this makes sense, and any help would be sincerely appreciated...
Here's an example of 2-d look-up using MATCH and INDEX, and it will work across sheets.
We use an Excel file as a support tracker. Our main sheet (A) has a list of users and their data. For daily support, we run the MYSQL stored procedure to get the data, then paste it into a blank sheet (B) that colors and filters the data.
I am supposed to search the users in sheets A and B, and if a user is present in B but not A (scenario representing adding a user to our system) add the missing user to sheet A.
Based on my past programming knowledge, the steps should be:
count rows in sheets A and B
A has more data further down the sheet that is not raw user data, but it is in the same columns so looking for the first blank cell in A
do a compare on those results
if the results are different, do a vlookup to find the missing entry
insert that entire row from sheet B to sheet A
I assume this can be done with VBA code.
You can write a VBA script to do this, and probably should if this is a regular process.
Alternatively a sorting approach will handle this and many similar problems. It works like this, given two sheets A & B with mixed duplicate and unique entries:
Append B to A
Sort by desired category (User in this case)
This will have duplicates (User) next to each other
Insert a match check column consisting of If User EQ PreviousUser, True, False;
Cut and paste Values to change from a function to simple content of True/False
Sort by True/False column
Delete the entire block of True's
Done!
This approach also works for more than two sheets. Append them all together, sort, mark dups, delete.
I need to do some aggregation and statistics on data and I'm thinking about doing that with Excel as the raw Data already comes in Excel format. Basically you could say it's kind of a log type of data with Datetime and some more information on each line.
I'm not yet clear what aggregation and other stuff needs to be done on this data but I already know that I need to merge new data into the then existing excel sheet every day or two. There is no real unique identifier in the data but the combination of 2 or more fields could easily be used for uniqueness. I wonder if there's a smart way to import the new data from time to time even if it contains already existing data then. Maybe something like copy it into a new tab/sheet then start some kind of import action where uniqueness gets checked?
I'm unsure if this can be done with Excel at all so please bear with me if the question sounds stupid to excel pro's.
Assume in a worksheet columns A and C can be combined for uniqueness. You could concatenate them to create an id:
In D2 = concatenate (A2,C2)
Then, add another worksheet of data, with this same concatenated column D added.
Then, add a third worksheet with a formula to only show unique data rows:
In worksheet 3 A2: =if(countif(sheet1!d:d,sheet2!d2))>0,"",sheet2!a2
In worksheet 3 B2: =if(countif(sheet1!d:d,sheet2!d2))>0,"",sheet2!b2
In worksheet 3 c2: =if(countif(sheet1!d:d,sheet2!d2))>0,"",sheet2!c2
This will create a sheet of unique ids with some rows (those that are unique) populated. You could copy and paste this as values only, the sort by any of the headings to get at the unique data only.
This is not the most efficient way to do this at all, but it will work in a pinch.
Is there a way to combine 2 Excel sheets (or groups of columns inside one Excel sheet) so that the rows in one sheet/group append to the other sheet/group where so that certain columns values match.
To clarify:
Lets say I have 2 sheets - Sheet1 and Sheet2. Sheet1 has the columns A,B,C,D. Sheet2 has columns A,E,F,G. Column A in both sheets contains the same data but differently sorted (it is not sorted in conventional way (alphabetically or numerically)). I need to combine these 2 sheets into one, but they need to be combined so that the values in A column match (if possible the result should be ordered in the same way as the Sheet2).
Ideally, the functionality I'm looking for would need to be like SQL's INNER JOIN command.
I'm using Excel 2007.
Thanks
I think you basically described the VLOOKUP function.
You have your two sheets, now you want to create a list, which extends A,B,C,D to A,B,C,D,E,F,G.
For that, you could just use
Sheet1!E1=VLOOKUP(Sheet1!A1,Sheet2!A:G,5,FALSE)
Sheet1!F1=VLOOKUP(Sheet1!A1,Sheet2!A:G,6,FALSE)
Sheet1!G1=VLOOKUP(Sheet1!A1,Sheet2!A:G,7,FALSE)
If you need to create an extra sheet3 as a result, use this:
Sheet3!A1=Sheet1!A1
Sheet3!B1=VLOOKUP(Sheet3!A1,Sheet1!A:D,2,FALSE)
Sheet3!C1=VLOOKUP(Sheet3!A1,Sheet1!A:D,3,FALSE)
Sheet3!D1=VLOOKUP(Sheet3!A1,Sheet1!A:D,4,FALSE)
Sheet3!E1=VLOOKUP(Sheet3!A1,Sheet2!A:G,5,FALSE)
Sheet3!F1=VLOOKUP(Sheet3!A1,Sheet2!A:G,6,FALSE)
Sheet3!G1=VLOOKUP(Sheet3!A1,Sheet2!A:G,7,FALSE)
Hope this interpretation was correct.
Edit:
By the way, because Excel is not mainly intended to function as a database, this operation is a bit messy, because it does not dynamically scale. At least with the second approach, using a thrid sheet. You will have to copy down A1 at least that far, to match the last used row from Sheet1. And if you should copy it down further, so you won't have to worry about it for a while, you might need to error-proof against the empty cells.