Excel merge columns - excel

Hi all I want to merge to columns in excel 2003.
For example:
Col1 Col2
------------
1 5
3 4
4 6
7 6
The merged column should look like this:
Col3
----
1
3
4
4
5
6
6
7
Thanks!!

Assuming, that your Col1, Col2 and Col3 are Columns A, B and C, you can use makro:
Range("A1:" & Range("A65536").End(xlUp).Address).Select
Selection.Copy
Range("C1").Select
ActiveSheet.Paste
Range("B1:" & Range("B65536").End(xlUp).Address).Offset(1, 0).Select
Selection.Copy
Range("C65536").End(xlUp).Select
ActiveSheet.Paste
Source: link

Although you could easily use Excel's built-in functions to copy and paste the values from each column into the third column, you don't state if it's a requirement that the results in Col3 need to be sorted, or whether duplicate values should be removed or not. If so, you might have to write a user-defined function (equivalent to an Excel macro) in Excel VBA to do this.
Your solution might look like this (pseudo-code):
Iterate through all rows in Col1 and store values in an array
Iterate through all rows in Col2 and store values in a second array
Create a new array and combine the values from the other two arrays
Output the values from the combined array into Col3
Your function/macro will probably need to accept three input parameters which would be the ranges of the two source columns and the output column.

Related

How do we split the columns in excet sheet into two columns based on the data present in the column?

I have data in one column i.e., Purchases as
Purchases
2 Pens
3 Books
4 Pens
1 Gifts
2 Books
I want to split it as
Col1 Col2 Col3
2Pens 3Books 1Gift
4Pens 2Books
In Excel O365, you could use in C1:
=FILTER($A1:$A5,ISNUMBER(SEARCH("* "&INDEX(UNIQUE(MID($A1:$A5,FIND(" ",$A1:$A5)+1,LEN($A1:$A5))),COLUMN(A1)),$A1:$A5)))
Drag the formula right.

Formula to dynamically create column of values, excluding some by criteria

Say I have a column with these values on Sheet1:
IDs
1
2
3
4
5
6
Then a column with these values on Sheet2:
Used IDs
2
3
6
Is there a clever way I can write a formula on Sheet3 that shows only the IDs that are visible on Sheet1 but NOT on sheet2? Like this:
Unused IDs
1
4
5
I need something that would update dynamically as move values are added to the
Used IDs' column on Sheet2. I can make something work that simply omits the used IDs (retaining their rows as NULL), like this:
Unused IDs
1
4
5
However, I need something without the blank rows.
put this in A1 in Sheet3 and copy down till blanks:
=IFERROR(INDEX(Sheet1!A:A,AGGREGATE(15,6,ROW(Sheet1!$A$1:$A$6)/(NOT(ISNUMBER(MATCH(Sheet1!$A$1:$A$6,Sheet2!A:A,0)))),ROW(1:1))),"")

Addition of hidden values from 4 columns

I have to make a system in excel wherein if I put ‘yes’ against three columns out of four columns then the total(hidden cost) must be calculated only on the basis of three columns.
Now I also have to put some numerical values which will be the cost of the respective column but this should be hidden.How to hide values
Example if I have hidden range say 10 in col 1,15 in col 2,30 in col 3 and 20 in col 4 then
if I put ‘yes’ in col 1 col 2 col 3 and ‘no’ in col 4 then cost must come out to be 55.
I am a beginner and struggling to work on it.Please advice.
have a look at the screenshot and imagine that the gray columns are hidden. To keep things simple the formula that checks for yes has been split accross 4 columns that will also be hidden =IF(B1="YES",A1,0) =IF(D1="YES",C1,0) etc. The formula in I1 is a sum of those 4 hidden columns =SUM(J1:M1)
Simpler version
This version puts all the hidden columns together and the sum can be calculated using a single formula.

Multiple value VLOOPUP

I've an excel with 2 sheets, the sheet 2 has some KV, my requirement is that, when I enter a key in sheet 1, it should get the corresponding values (spread across many columns & rows).
Sheet2:
A B C D
1 Obj1 Item1 Price1 Qty1
2 Item2 Price2 Qty2
3 Item3 Price3 Qty3
4 Item4 Price4 Qty4
Note: Obj1 is merged for 4 rows in col1.
In Sheet1 if I enter Obj1, I want all the values present in column B, C, D & the rows 1, 2, 3, 4.
I tried the option
{=vlookup("Obj1", Sheet2!A:D, {2,3,4}, false)}
But does not return 3 columns as expected. (I read this method of returning multiple columns in some website)
Kindly help me to resolve this.
Use a helper column:
In E1 put:
=A1
In E2 put
=IF(A2<>"",A2,E1)
Then put this formula in the upper left corner of the desired output range:
=IFERROR(INDEX(B$1:B$4,AGGREGATE(15,6,ROW(B$1:B$4)/($E$1:$E$4=$G$1),ROW(1:1))),"")
Where $G$1 is the location of the Search Criteria.
Then drag/fill this formula across a total of three columns and down enough rows to cover the greatest number of rows that a object can have.
Of course once you have your helper column you can easily use it with filters to output the same thing without the formulas.

How to get sub ranges from pivot table

I have a table like this
col1 col2
a 1
a 2
a 3
a 4
a 5
b 6
b 7
b 8
b 9
b 10
I want to write a PERCENTILE function for each group in col1. Is there a way by pivoting this table and writing custom function PERCENTILE. But calculated field in pivot table is not allowing to write functions. I have to do this without VBA
I have to write, to find average of top 70%, something like below. But how to get sub ranges?
col1 col2
a =AVERAGEIF(B1:B5,">"&Percentile(B1:B5,0.7))
b =AVERAGEIF(B6:B10,">"&Percentile(B6:B10,0.7))
You could do that with an array formula since the percentile function accepts arrays:
=PERCENTILE(IF($A$2:$A$11=D2,$B$2:$B$11,""),0.7)
This needs to be entered as an array formula with ctrl+shift+enter.
{=PERCENTILE(IF($A$2:$A$11=D2,$B$2:$B$11,""),0.7)}
Just auto-fill that down the column. Let me know if you need an example of how to copy-paste the unique values of a column.
You can test it like so if you want. It works:
=PERCENTILE(B7:B11,0.7)
Good Luck.

Resources