Select neighbouring cells of a cell with a specific value in excel - excel

I have a data set in excel with four columns;
Username, Computer, Department information
I have used a filter to select all unique usernames in the data set, then have used counif() to count how many times the username occurs in the data set - This works fine.
Now I want to search the original data set for every time a specific username appears and when it does, I want to select the 'information' cell to that relevant row. So the output will be an array rather than one value,
example,
Username|Information
A 1
A 2
B 3
A 4
D 5
So if I use my function to search for all values from 'information' with username A, I want this to output,
Information
1
2
4
Thanks.

Here's one method that doesn't involve VBA. It may not be practical for your needs though.
Make a pivot table based on your data
Add Username to the Filter
Add Information as a Row
Change the Filter from (All) to your desired username.
If you need to rerun the underlying dataset, just right click to refresh the pivot table.

Related

VLOOKUP to bring data from another sheet

I have a table containing a some football data, such as Country, League, Teams, Standing table information, such as total matches played, wins, draws, losses, goals scored and conceded, and so on.
Here's a file download link
It contains two sheets.
First sheet is STANDINGS_EXTENDED:
I need to fill these 3 tables with the data contained in another STANDINGS worksheet.
Here's a screenshot of the STANDINGS sheet:
My aim is that once I fill LeagueId and Group Id (which is optional) fields then inside all three tables will be produced the data as in this sample.
I wonder if it is possible to achieve this without VBA. But i have no clue on where to start from. I tried is several different ways, but i get only first result from STANDINGS worksheet for any league i enter.
Looking forward to your help.
Thank you!
UPDATE:
So far I could get the count of rows related to Overall, Home and Away using these formulas:
=COUNTIFS(STANDINGS!E:E;STANDINGS_EXTENDED!E1;STANDINGS!F:F;"StandingsOverall")
=COUNTIFS(STANDINGS!E:E;STANDINGS_EXTENDED!$E$1;STANDINGS!F:F;"StandingsHome")
=COUNTIFS(STANDINGS!E:E;STANDINGS_EXTENDED!$E$1;STANDINGS!F:F;"StandingsAway")
Also, what I can get is the first row of these results using this formula:
=VLOOKUP($E$1;STANDINGS!$E:$V;4;FALSE)
What I need to figure out is how to modify above formulas so that I fill tables with remaining rows.
In order to do this you need a formula in every single field of your 3 tables that link it to data on the Standings tab. That would be 13 x 3 x 20 formulas. Therefore one would try to create formulas that can be copied, in the best case less than 13 original ones, but definitely one formula for each field.
Each formula would look for a unique identifier in the Standings list. I can't see any unique identifiers there but you might create them by concatenation, such as "League" + "Country" + "Position". The more detail you need the larger the formula. The key is: without a unique identifier for each row you can't retrieve data. But once a row has been identified you can get the value from any of its columns.
If your tables sometimes have 12 rows, sometimes 20, and sometimes 25 you must provide space for the possible maximum and then design your formulas to return a blank if there is nothing to display.
In conclusion, the core of your system is in the Standings table. It must be set up so that data can be retrieved from it. Ideally, your selection on the Standings Extended sheet would generate a concatenated unique identifier for a list to which you can add the fixed number in the Pos column to identify individual rows in the Standing table. As long as you can't identify rows no data can be retrieved.
Using VBA gives you more flexibility but doesn't relieve you of the task to create uniquely identifiable rows.

Compare users in different sheets and add user to sheet A if not present in A but present in B

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.

Restructuring data in excel

I am trying to condense data in a specific way. I want any occurrences of the number 1 in each column to show up as 1 (regardless of how many times it occurs) with the corresponding site, in the corresponding column. Some sites occur multiple times in the original data, and I want to make it so that only one of each unique site shows up in the resulting data table with a 1 for the corresponding column if there any 1's in the column from the original data.
I would think it would be a vlookup function, but I have tried many different things and I am really stuck on this.
Image of original data and what I am trying to do:
Thank you
This assumes that your data set only contains 1 or blank and this approach uses a Pivot Table with MAX function. Below are details in case anyone doesn't know Pivot Tables.
Select a cell in your data and insert Pivot Table. Note, I added a title for column A, as you need that in the Pivot Table.
Click in the created Pivot Table and the PivotTable Fields dialog should pop up. If not, right click in Pivot Table and select Show Field List.
Drag the Field names (Code, a, b,& c) down to the appropriate blocks below. (Values under Columns will be created for you.)
Click on the drop down arrow next to each field name and select Max. That will rename it to "Max of ...". If that bothers you, then you can type the name you want into the Custom Name field. Note, it will not let you type the same name as the field name, eg a, but it will work if you put a space in front of it.
Given that the Pivot Table would be a lot of work for a large number of columns, here is a formula based approach. Put this formula in cell G2, then drag it down and across to fill your new table.
Note, you will have to populate all codes that you have in column F. And if any new codes are added later you will have to keep this updated. One of the advantages of a Pivot Table is that it will do this for you.
I know that you won't be putting this in these cells, so adjust accordingly. In fact, I would recommend this be in another sheet.
=IF(COUNTIFS($A:$A,$F2,B:B,1)>0,1,0)
COUNTIFS($A:$A,$F2,B:B,1)
This will count each occurrence when the value in column A matches your code $F2 AND the value in column B equals 1.
If that count is >0, then you know that at least one match was found and the IF will return 1, otherwise 0.

Count row with multiple values in excel

I have excel sheet contain 600 thousand row, I want to select one column.
for example please see the attachment picture
Here in the column there are multiple values, I want to count it and the result must be for example
number of value 1 it's = 55
number of the value 8 it's = 23
seems this to do it's easy but I have 600 thousand with multiple values.
It all depends on how many times you have to change the column and what you have to do with the informations you get.
Without this info the best solution is the following:
select the column you have to analyze;
push Insert;
hit Pivot table
select Pivot Table.
Now you have only one field that you can put inside ROWS and inside VALUES (select COUNT).
This will give you an unique list of the elements and the amount of each one.

Pulling information from 1 worksheet to another, based on drop down list selection

I am trying to get a spreadsheet to auto populate rates for products, based on the size of the order, which are chosen from a drop-down menu.
I am using 2 workseets - Sheet 1 has a data validation drop down list of the Order Sizes (0-49, 50-99, 100+), and another column of Products, where I would like the rates to come across. Sheet 2 has 3 tables - One table per Order Size, containing the products' rates for that size order (Table 1 = 0-49, Table 2 = 50-99, Table 3 = 100+).
I can't figure out how to get the rates from the 3 tables (on Sheet 2) to pull across and auto-populate in the Products column (on Sheet 1), once I've chosen the Order Size from the drop down list (on Sheet 1).
I hope that makes sense. Unfortunately I'm too new to this site, so it won't let me post images or files
I don't really understand Macros or VBA, so please dumb it down for me :-) Thank you!
You can accomplish this without using any VBA by making use of the IF and VLOOKUP functions. I'm assuming your data looks like this:
The formula in B8 is:
=IF(B2="0-49",VLOOKUP(B5,Sheet2!A3:B5,2,FALSE),IF(B2="50-99",VLOOKUP(B5,Sheet2!A8:B10,2,FALSE),IF(B2="100+",VLOOKUP(B5,Sheet2!A13:B15,2,FALSE),"Enter a valid order size selection")))
Basically the IF statements tell it which table to look in, based on the selected order size, and the VLOOKUP statements do the looking up based on the selected product. An IF statement takes the form of:
IF(logical_test, [value_if_true], [value_if_false])
So, this first checks if the value of B2 is "0-49." If it is, it performs the lookup in the small order table. If it's not, it goes on to check if the value is "50-99." Etc. Then, at the end, if the value isn't any of the options, it prompts the user to enter a valid order size.
See:
http://office.microsoft.com/en-us/excel-help/if-function-HP010342586.aspx
http://office.microsoft.com/en-us/excel-help/vlookup-HP005209335.aspx

Resources