I have an excel sheet that has names and extension numbers. The sheet is designed to be printed as a reference and so it has the data split into 3 columns like how a newspaper is laid out.
EXT Name EXT Name EXT Name
1 bob 4 pete 8 sam
2 dave 5 sally 9 john
I need to have excel sort this data on name, A-Z. I can only work out how to make it sort one column at a time and so I end up having to manaually sort the data every time I add or remove information.
Can excel sort all 3 columns top to bottom and left to right?
Thanks!
Maybe this KB artikel helps.
Or u can try using the small function like
Column A
=SMALL($A$1:$A$9;0+ROWS(A$1:A1))
Column C
=SMALL($A$1:$A$9;30+ROWS(A$1:A1))
In this case you clone the sorted dataset, which is in two columns
The value for the B colums can be found using a vlookup. the value 0 and zero are an offset, so the length of the page is fixed
Related
I'm not sure exactly how to explain this, but I want to combine rows in Excel while condensing the column data. I'm looking to take a spreadsheet like this:
Name
Coffee
Bananas
Chocolate Ice Cream
Tom
4
Tom
2
Tom
2
Jerry
1
Jerry
4
Amanda
3
Amanda
2
and turn it into this:
Name
Coffee
Bananas
Chocolate Ice Cream
Tom
4
2
2
Jerry
1
4
Amanda
3
2
Any tips would be super helpful.
You can setup a pivot table for this.
Select your table > Insert Pivot Table, then follow this screenshot:
Drag Name colum in Rows
Drag Coffee, Bananas, Chocolate ice creams in Values and you're set!
If you want the data transformed and cleansed, you can always use PowerQuery.
Go to Data -> Get Data -> From File -> whatever source your data is in.
In there, use the Group By function to suppress the rows.
From there, you'll have a new set of data which can then be loaded into the destination worksheet.
If the usage of PowerQuery is new to you, a quick Google search will help you through this.
Naturally, this assumes you have a version of Excel that has PQ built in.
Here/screenshot(s) refer:
Condensed table comprises 3 sections (colour coded respectively):
Row labels (names, blue) - assuming these are unique at source
Column labels (food product, green) - ditto
Values (sum per row / col label, yellow)
note: included an extra '1' for Tom + Chocolate IC in 1st row for testing...
1] Row labels
=UNIQUE(D7:D13)
(array function - requires Office 365 compatible version of Excel)
2] Col labels
=E6:G6
(array function - enter in single cell if using Office 365 compatible version of Excel, otherwise highlight relevant area and enter function with shift + alt + enter)
3] Values
=SUMIFS(INDEX($E$7:$G$13,0,MATCH(J$6,$E$6:$G$6,0)),$D$7:$D$13,$I7)
(can drag this function across values / yellow section)
I have an Excel sheet with the below data.
There are 10,000 Data rows.
9000 are of "USA" & 1000 are of "Other" country.
I want to evenly distribute the data so that when I have 9 "USA" followed by 1 "Other" data distributed throughout.
Name
Country
Alice
USA
Brook
Other
Cathy
USA
David
USA
Esther
Other
Freddy
USA
Galin
USA
Henry
Other
Indigo
USA
Jenny
USA
Kalin
Other
Linda
USA
How do I accomplish this using manual & excel VBA? Appreciate both solutions. Thanks
This can be achieved with a formula if you have the newest version of Excel.
Try something like (adapt ranges and what you are filtering on as necessary):
=LET(x, FILTER($B$1:$C$12, $C$1:$C$12="a"),
y, FILTER($B$1:$C$12, $C$1:$C$12="b"),
z, ROW(D1:D12), myrows, MAX(z),
ratio, MAX((COUNTA(x)/2)/(COUNTA(y)/2), (COUNTA(y)/2)/(COUNTA(x)/2))+1,
IF(MOD(z,ratio)<>0,
INDEX(x, IF(MOD(SEQUENCE(myrows),ratio)=0, 0, SEQUENCE(myrows)-CEILING(ROW(G1:G12)/ratio-1,1)), SEQUENCE(1,2)),
INDEX(y, IF(MOD(SEQUENCE(myrows),ratio)<>0,0,SEQUENCE(myrows)/ratio), SEQUENCE(1,2))))
For example:
The trick is to create the "correct" sequence for each result; for the first array you want to skip every nth row (in your case 10), and having the nth+1 row not default to n+1, but n, while in the second array you want to skip every row that isn't a some multiple of n, and have the nth rows count sequentially.
A caveat-- as is, I don't believe the formula will work with repetition other than 1, i.e. if you want to do something like 8 rows followed by 2 rows, this won't work.
This works even with older Excel versions:
If this is your data:
Add a Sort column with the following formula in C2 and pull it down:
=IF(B2="USA",COUNTIF($B$2:B2,"USA")+INT((COUNTIF($B$2:B2,"USA")-1)/ROUNDUP(COUNTIF(B:B,"USA")/(COUNTA(B:B)-COUNTIF(B:B,"USA")),0)),COUNTIF($B$2:B2,"Other")*(ROUNDUP(COUNTIF(B:B,"USA")/(COUNTA(B:B)-COUNTIF(B:B,"USA")),0)+1))
Then sort by this column C and USA and Other are evenly spread:
enter image description here
I want to sum all these data given in right side to my format. I tried many time and many formulas but some things left every time. Please help
You can achieve most of what you need with a mixture of formulae and a pivot table. But I couldn't quite get everything you wanted, as some of it doesn't make sense. For example, you have 2013 - 2012 - <5 as your first row header, but there are multiple years that give an age less than 5, e.g. 2014 - 2013 - <5 would also be valid. I would suggest hardcoding the years somehow, as they aren't entirely relevant anyway?
Breaking it down into separate problems.
How do I get the Roman number version of the Class?
You could have a massive IF statement, but I went for a VLOOKUP. You could have used the ROMAN built in function, but you can't because your numbering is "first", "second", etc. instead of "1", "2", etc.
So I actually went for both solutions, just to show how they both work. First I created a named table (list object) called "Named" that looks like this:
Class Class Number
First 1
Second 2
Third 3
Fourth 4
etc.
I then used this to VLOOKUP your class names and convert them into numbers. Next I used the ROMAN function to make this into roman numeral format. So I ended up with this (columns E, F and G in my worksheet):
Class Class Number Roman
First 1 I
First 1 I
First 1 I
First 1 I
First 1 I
Second 2 II
Third 3 III
Fourth 4 IV
With formulae:
Class Number - =VLOOKUP(E2,Named,2,FALSE);
Roman - =ROMAN(F2).
How do I get from "Male"/ "Female" to "B"/ "G"?
This was trivial, just =IF(A2="Male", "B", "G") where I have Gender in column A.
How do I get the "age text" so it handles "<5" and ">22"?
My age was in column D, so this was also trivial, =IF(D2<5,"<5", IF(D2>22, ">22", D2)).
Now I have enough data to pivot, so I selected my entire table, which was basically your sample data with calculated columns added to the right. Then I inserted a pivot table and dragged in row/ column headers to make it match your format. This doesn't give you the year columns, but it gives you everything else. For example, just using a few random rows of sample data (as I couldn't be bothered to type it all in):
I went from:
Gender Date of Birth Age Class
Male 06-Jan-14 4 First
Female 07-Sep-11 6 First
Male 01-Jan-12 6 First
Male 31-Dec-12 5 First
Female 01-Oct-11 6 First
Female 16-Nov-10 7 Second
Male 31-Oct-09 8 Third
Male 25-Oct-10 7 Fourth
To:
I II III IV
B G G B B
<5 1
5 1
6 1 2
7 1 1
8 1
Total 3 2 1 1 1
From here you could simply hardcode the columns A and B from your desired final format, as these years aren't actually based on the data?
I have a list that I'm checking against the main data.
The main data looks like:
1234 1
1235 1
1234 1
1213 2
1231 2
1212 2
1231 3
1231 3
etc
The list I'm checking against the main data is:
1
2
3
etc
For each number in my list, I want to count how many start with 123, so the output looks like:
ID 123
1 3
2 1
3 2
etc
I have each ID in the list already. To drag down for each number, I currently have countifs(a1:a8, a1,b1:b8, "123") and it's obviously producing an error. I know I need to include left somewhere in here but I'm not sure where or how to. Much thanks.
In the Main Data sheet, add a column and enter formula as eg: C1=IF(LEFT(A1,3)="123",1,0). Drag the formula for every C cell. Then use that C cell in your SUMIFS in your list sheet eg: =SUMIFS(C:C,B:B,"="&E1) E col for me is your list.
Please refer screenshots below.
Identify begins with 123
sumifs to get the output
Edit:
Another Solution: =SUMPRODUCT(--(LEFT(Maindata!$A$1:$A$8,3)="123")*(Maindata!$B$1:$B$8=Maindata!D1)). This solution works fine to me.
sumproduct with --left
You can use someproduct to do this:
=sumproduct((Maindata!$A$1:$A$8=A1)*(left(Maindata!$B$1:$B$8)="123"))
Where A1 holds the digit you're determining the amount of "values that start with 123" for, and the main data is in worksheet Maindata, range A1:B8.
Is your data in the form of text or number values? If the former, your criteria should instead be "123*" (using an asterisk for wildcard), if the latter you might be able to get away with using ">1230".
I'd like to accomplish the following task. There are three columns of data. Column A represents price, where the sum needs to be kept under $100,000. Column B represents a value. Column C represents a name tied to columns A & B.
Out of >100 rows of data, I need to find the highest 8 values in column B while keeping the sum of the prices in column A under $100,000. And then return the 8 names from column C.
Can this be accomplished?
EDIT:
I attempted the Solver solution w/ no luck. 200 rows looks to be the max w/ Solver, and that is what I'm using now. Here are the steps I've taken:
Create a column called rank RANK(B2,$B$2:$B$200) (used column D -- what is the purpose of this?)
Create a column called flag just put in zeroes (used column E)
Create 3 total cells total_price (=SUM(A2:A200)), total_value (=SUM(B2:B200)) and total_flag (=(E2:E200))
Use solver to minimize total_value (shouldn't this be maximize??)
Add constraints -Total_price<=100000 -Total_flag=8 -Flag cells are binary
Using Simplex LP, it simply changes the flags for the first 8 values. However, the total price for the first 8 values is >$100,000 ($140k). I've tried changing some options in the Solver Parameters as well as using different solving methods to no avail. I'd like to post an image of the parameter settings, but don't have enough "reputation".
EDIT #2:
The first 5 rows looks like this, price goes down to ~$6k at the bottom of the table.
Price Value Name Rank Flag
$22,538 42.81905675 Blow, Joe 1 0
$22,427 37.36240932 Doe, Jane 2 0
$17,158 34.12127693 Hall, Cliff 3 0
$16,625 33.97654031 Povich, John 4 0
$15,631 33.58212402 Cow, Holy 5 0
I'll give you the solver solution as a starting point. It involves the creation of some extra columns and total cells. Note solver is limited in the amount of cells it can handle but will work with 100 anyway.
Create a column called rank RANK(B2,$B$2:$B$100)
Create a column called flag just put in zeroes
Create 3 total cells total_price, total_value and total_flag
Use solver to minimize total_value
Add constraints
-Total_price<=100000
-Total_flag=8
-Flag cells are binary
This will flag the rows you want and you can grab the names however you want.